Fork me on GitHub

A few days ago in the #clojure channel someone said: "i've just realized (= '(1 2 3) [1 2 3]) => true" if for some reason i don't want this behavior, what can I do?"


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


I've written an article once where I explained only briefly the reasons for this behavior as follows: "it was considered useful and convenient". That might be leaving out much better arguments, and I was curious if anyone had any in mind, and/or articles that go into that decision in more depth.


It is useful and convenient in many ways. I can also think of cases where it makes programs more efficient, because you do not need to convert between different sequence types before comparing them using an imagined strict-= that only returned true if the sequential things being compared had the same type.

Alex Miller (Clojure team)22:09:03

The main thing is that we frequently switch sequential types, most obviously from concrete colls like lists and vectors to seqs, but other cases too

Alex Miller (Clojure team)22:09:52

Blurring those lines is really important to make working with seq functions low friction

Alex Miller (Clojure team)22:09:47

Whenever possible I try to write code that is agnostic to the type of the sequential coll

Alex Miller (Clojure team)22:09:52

Auto seq on seq function inputs is in same ballpark