This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-15
Channels
- # 100-days-of-code (7)
- # beginners (58)
- # boot (1)
- # cider (12)
- # clojure (69)
- # clojure-nl (1)
- # clojure-serbia (1)
- # clojure-spec (34)
- # clojure-uk (3)
- # clojurescript (14)
- # clojutre (3)
- # core-async (1)
- # core-logic (6)
- # cursive (44)
- # datomic (1)
- # defnpodcast (1)
- # emacs (16)
- # figwheel-main (3)
- # fulcro (14)
- # immutant (3)
- # leiningen (9)
- # mount (1)
- # nrepl (19)
- # off-topic (4)
- # pedestal (2)
- # re-frame (73)
- # ring (2)
- # shadow-cljs (40)
- # tools-deps (14)
- # yada (4)
hello, i've just realised (= '(1 2 3) [1 2 3]) ;;=> true. if for some reason i don't want this behavior, what can I do?
You can add an additional check on type, but I would really suggest that you try relaxing your expectations
The reasons for this are subtle and important and in many ways essential for Clojure to be what it is
(identical? '(1 2 3) [1 2 3]) ;;=> false
@pbaille depending on the reason you don't want it, you can do things like (and (seq? x) (seq? y) (= x y))
, (and (= (type x) (type y)) (= x y))
what i'm reluctant to do is wrap this kind of check around core/= (for performance reason, but maybe i should not care)
@porkostomus does identical? compare things by value or by reference?
I just realized that's not what you want because (identical? [1] [1]) ;;=> false
it has to be the same object
A word of warning from https://clojure.org/guides/comparators - "Do not write a boolean comparator that returns true if the values are equal. Such a comparator is inconsistent. It will cause sorted collections to behave incorrectly, and sorting to give unpredictable orders."
To be clear, boolean comparators are not =
by definition. Boolean comparators are <
-- a total ordering.
(so, really, that has nothing to do with what @pbaille is asking about)
I did realize that eventually.. I probably shouldn't be trying to give advice
@pbaille If you want (= '(1 2 3) [1 2 3])
=> false
, then my recommendation would be to modify the relevant Clojure implementation parts, written in Java for Clojure on the JVM, that make it true. I would expect that if you change that behavior of clojure.core/=, then some other parts of Clojure's implementation that expect the current behavior may break and need changing.
This is bad advice
I think it would be much more fruitful to work to understand this aspect of Clojure
Agreed that it would be an arduous task that might not end up where they want, hence my "If". Also agreed that trying to change someone's mind about the goal is a better idea.
Note: I am not saying that I have tried making such a change and I know from experience that something else will break as a result. But such a design decision is pretty fundamental in Clojure, so it would surprise me if nothing else in Clojure's implementation relied upon that. A lot of Clojure is written in Clojure.
@andy.fingerhut modifying clojure implementation is not something that I consider for such things 🙂 but maybe one day to hack the reader or some other things. thank you for your help
@porkostomus 🙂 i think one should always try, i appreciate your advices.
Can anyone explain to me the purpose of vector-of
? It stores primitives unboxed, but I can't find the way to retrieve those primitives from it without boxing.
Better memory use, but you’re correct re boxing. You really need Java arrays to avoid that.
Thanks, Alex. Is it correct to say that this is an unfinished experiment rather than something complete? I don't think I ever saw it used anywhere. Are there any hypothetical plans to pursue this direction further?
It accomplishes the goal of much more efficiently storing a vector of primitives
We have talked about ways to extend the standard IFn to support primitive longs and doubles. If we did so, then it would actually be possible to extract primitive longs and doubles from vectors of those.
I think unless it's a personal project and it's just for fun @pbaille none of your colleagues will probable appreciate a change like that
Assuming there is a way (which probably is just forking clojure anyway)
@andrea.crotti yes i agree, for better or worse i have no colleagues currently, neither production targeted project 😉
does cognitect works on 2.0? (with breaking changes) just curious... (i'm aware of rich's spec-ulation, so maybe i should not ask but... (ps: this is not related to my last question)).
No plans for a 2.0 right now. Next release will be 1.10
@U064X3EF3 thank you
So I think I’m gonna need to give my maps a :type
keyword even though they have namespaced keys to make writing a multimethod easy…
(->> my-maps
(mapcat :x)
(apply concat)
(apply hash-map))
feels like abusing apply
when things might get longtriss i'm afraid there is lack of background information to give you good advice
i would not worry about the cpu overhead too much
it's more a question of context .... i have seen code where conform can be a nice clean readable solution but i have also seen ruby monoliths aged 10 years which are a mess due to using similar approach as a hammer, and over there these things have 9 legs and 3 eyes and you don't want to be there 😞
deps.edn
form-validator {:local/root "../form-validator-cljs"}
How to configure deps.edn to make reload ns after change in form-validator module?
@kwladyka That's out of scope for clj
and deps.edn
-- you can (require ... :reload)
in the REPL tho'...
Best practice is probably building something based on Component (or something similar) and baking the whole start/stop/reload thing into your REPL workflow...
hmm but on the other hand it will make “fake complex” example how to use this module. My intention is to have: repo form-validator and form-validator-demo, which I will use for demo and manual tests in web browser during developing.
I'm not really understanding what you're asking at this point if my answers aren't helping 😞
it helps, but while I can’t make this reloading simple I am thinking if my assumption about how to develop this module are right
1) repo form-validator
with code and tests in REPL
2) repo from-validator-demo
which depends on form-validator
and it is about use in web browser
Asking in different words: Like I am doing it now is ok? Would you do it in the same way?
hmm actually how to reload ns from the code? I could maybe use this:
(defn ^:before-load before-reload []
(require 'form-validator.core :reload))
But Calls to 'require' must appear at the top-level.
That must be a ClojureScript limitation. You can call require
programmatically like that in Clojure.
Try asking in #clojurescript and see what folks recommend there.
I can't help with cljs -- I only do Clojure. Sorry.
Make sense. Thanks @U04VDQDDY