This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aws (2)
- # bangalore-clj (1)
- # beginners (25)
- # boot (2)
- # cider (176)
- # clara (73)
- # cljs-dev (6)
- # cljsrn (31)
- # clojure (40)
- # clojure-greece (9)
- # clojure-india (1)
- # clojure-italy (14)
- # clojure-nl (9)
- # clojure-russia (4)
- # clojure-uk (156)
- # clojurescript (124)
- # core-async (37)
- # cursive (2)
- # data-science (2)
- # datomic (22)
- # emacs (3)
- # fulcro (32)
- # graphql (6)
- # java (3)
- # lein-figwheel (19)
- # lumo (29)
- # nyc (1)
- # off-topic (9)
- # onyx (15)
- # portkey (12)
- # precept (2)
- # re-frame (15)
- # reagent (10)
- # rum (7)
- # schema (2)
- # shadow-cljs (48)
- # tools-deps (35)
- # yada (1)
I was wondering what kind of wisdom lies at the heart of the following fact: control of whether a macro expansion should be spliced in the parent form or simply expanded belongs to the parent. If we could control the splicing of a macro-expansion from the macro itself, what kind of challenge would this pose ? Is there any Lisp from the past that has attempted this ? One edge case I can foresee is when the macro is already the top level form and there is no parent to splice into. Making the macro splice into a progn/do form could be a way to overcome this.
if forms were allowed to transform their parents, you wouldn't understand a form without knowing exactly what gets put into it, so clojure (and most lisps similarly) only allow control from outside in
Why do I need the type hints here? using
(def dtf (DateTimeFormatter/ofPattern "yyyy-MM-dd")) (def now (LocalDateTime/now)) (def today (.format ^LocalDateTime now dtf)) (def tomorrow (-> ^LocalDateTime now (.plusDays 1) (.format dtf)))
That's strange since it works perfectly ok for me. java 8, clojure 1.9.
I'd assume that it could have some problems if the value you pass there (`now`) would be of more then one possible type that overloaded
format method accepts but that's not the case I guess.
@U04V15CAJ is that an actual compile error—or is it the warning IntelliJ gives you when you try to ⌘-click through
.format to get to the definition? I’ve seen the latter using Cursive, in cases where the code works fine at runtime. @U06BE1L6T’s point is apt.
boot.user=> (import '[java.time LocalDateTime] #_=> '[java.time.format DateTimeFormatter]) java.time.format.DateTimeFormatter boot.user=> (set! *warn-on-reflection* true) true boot.user=> (def dtf (DateTimeFormatter/ofPattern "yyyy-MM-dd")) #'boot.user/dtf boot.user=> (def now (LocalDateTime/now)) #'boot.user/now boot.user=> (def TODAY #_=> (.format now dtf)) Reflection warning, null:2:3 - call to method format can't be resolved (target class is unknown). #'boot.user/TODAY
Ok, I didn't get it. I assumed you're getting an error (not warning) that method can't be resolved
I guess the situation with global defs is similar to function args (clojure cannot know the type of the argument in advance - it's just
Here's a mention about "local contexts": https://clojure.org/reference/java_interop#primitives
> They can be placed on function parameters, let-bound names, var names (when defined), and expressions https://clojure.org/reference/java_interop#typehints
I re-formulated the question here: https://clojurians.slack.com/archives/C03S1KBA2/p1526979789000238
cool - may be worth to update snippet with setting
*warn-on-reflection* and printed warning.
instance? is closer since with
satisfies you actually check "instances" (e.g. instance of defrecord) not "classes".
(instance? java.util.Comparator (fn ))
Is anyone aware of any library which can create a kubernetes cluster on aws? Like Kops in Go?
(new java.io.OutputStream) result in
java.io.OutputStream is an abstract superclass, you need to create an instance of some specific subclass like
I guess my real question is, how do I get something writable that is convertible to an InputStream? I have a lazy seq I am converting to CSV.
I think a
ByteArrayOutputStream might be useful here, because you can get the bytes with
toByteArray() and pass them as a constructor arg to
Apparently I was in this mess originally because something was trying to convert my working solution with Channel/newWriter & Channel pipes into a ByteArray. Bypassed that and now it's all working.