This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-29
Channels
- # beginners (1)
- # cider (7)
- # cljsrn (6)
- # clojars (3)
- # clojure (35)
- # clojure-nl (2)
- # clojure-spec (5)
- # clojure-uk (9)
- # clojurescript (18)
- # clojurex (1)
- # community-development (2)
- # cursive (27)
- # datomic (12)
- # duct (11)
- # emacs (5)
- # hoplon (5)
- # immutant (2)
- # leiningen (1)
- # luminus (15)
- # nyc (1)
- # om (9)
- # om-next (5)
- # onyx (55)
- # parinfer (1)
- # re-frame (3)
- # reagent (44)
- # reitit (11)
- # ring-swagger (4)
- # shadow-cljs (25)
- # videos (1)
@mfikes the truth is, I've been lying to you this whole time. native-image
just spins up your CPUs and stores the cycles. Later when the output of native-image
is running that CPU power is slowly released to improve the overall performance of your program.
that's --hansnfranz
1. I do a deftype / defrecord, and create some objects. Call them OLD objects. 2. I modify some member function of a deftype/defrecord, of some protocol. 3. Now, is there anyway to get all the "OLD OBJECTS" to promote to the new member functions ?
correct, because there you deal with the ILookup / keyword abstraction found in defrecords
defmulti prevents reloading, but defmethod avoids the problem - if you need to redefine defmulti's dispatch that can lead to odd things though
which will work anywhere else, code against defrecord with (:kw record) vs (.-kw record) and it will work fine
(defn real-foo [obj] ...) (deftype Foo IFoo (foo [this] (real-foo this))) would solve the problem right?
I guess? but in that case, why use deftype in the first place?
I like deftype to (1) specify which protocols it satisfies and (2) make explicit the members (instead of adhoc maps)
a good rule of thumb: stick with multi methods and maps until you benchmark a working app and see them to be too slow
I'm not trying to do this for performance reasons. I find that defprotocol helps with abstration and deftype makes it explicit what the members are. With a map I'm always guessing "what keys should this have"
re: graal and native image, I hope someone will come up with a leiningen plugin for that
When m
is a map and :key
is a keyword, you can do either (:key m)
or (m :key)
— is there a practical difference or does it come down to style? Is there a preferred form?
Thanks — any rationale behind it? I get that doing (:key m)
makes it immediately obvious that m
is a map, whereas (m :key)
could be any function call, esp. if the map is named something more descriptive.
The main difference is that if m
is nil, (m :key)
will throw whereas (:key m)
won't
@cryan Normally you'd fully qualify the symbol, using the help of syntax quote:
(spec/exercise-fn `zipcode-or-place)
@mfikes yeah, if i manually type out the fully qualified symbol, it works, but for some reason when i call it with the backtick, i get the error.