Fork me on GitHub

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?

Alex Miller (Clojure team)11:09:45

You can add an additional check on type, but I would really suggest that you try relaxing your expectations

Alex Miller (Clojure team)11:09:45

The reasons for this are subtle and important and in many ways essential for Clojure to be what it is

Bobbi Towers05:09:06

(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))


yes that's what i'm doing, but i was hoping for a builtin


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?

Bobbi Towers05:09:03

I just realized that's not what you want because (identical? [1] [1]) ;;=> false

Bobbi Towers05:09:14

it has to be the same object


yes that's what i was suspecting

Bobbi Towers05:09:28

A word of warning from - "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)

Bobbi Towers05:09:11

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.

Alex Miller (Clojure team)11:09:49

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.

Alex Miller (Clojure team)11:09:04

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?

Alex Miller (Clojure team)13:09:08

It accomplishes the goal of much more efficiently storing a vector of primitives

Alex Miller (Clojure team)13:09:11

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.


Thanks for clarification.


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)).

Alex Miller (Clojure team)10:09:41

No plans for a 2.0 right now. Next release will be 1.10


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…


Is that an antipattern in Clojure these days?


Part of me feels like I could s/conform and choose to dispatch off the result of that.


but that feels expensive…


(->> my-maps
  (mapcat :x)
  (apply concat)
  (apply hash-map))
feels like abusing apply when things might get long


(into {}
      (mapcat :x)
      (map vec))


triss 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 😞


has anyone experience with a JavaFX wrapper in clojure?


Maybe the fn-fx? Slack/ fn-fx channel. @roti


deps.edn form-validator {:local/root "../form-validator-cljs"} How to configure deps.edn to make reload ns after change in form-validator module?


I need it during developing module


@kwladyka That's out of scope for clj and deps.edn -- you can (require ... :reload) in the REPL tho'...


Is it best practice nowadays?


Alternative way to develop module? This one is actually about cljs.


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.


Am I have bad assumptions?


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


Can I do my assumptions about how to develop module and example code better?


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.


ok I guess it is not possible


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.


Right, you can't put a require inside of a function like that in ClojureScript.


TL;DR reason: in ClojureScript functions are runtime, while require is compile time