4 ms·
Some people like Clojure syntax rather than S-expressions. Personally I don't get it, having arbitrary lists that require square instead of round brackets, arb
by tmtvl 3y ago
Some people like Clojure syntax rather than S-expressions. Personally I don't get it, having arbitrary lists that require square instead of round brackets, arbitrary lists where pairs which belong together aren't grouped, and arbitrary lists where commas are interpreted as optional whitespace gives me a headache; but to each his own.
- jakebasile 3y agoClojure still uses S expressions, it just has more than just lists available. Square brackets don't make lists, they make vectors. Commas are always optional. I don't know what you mean by "arbitrary lists where pairs which belong together aren't grouped", but maybe you mean maps or sets, which are also not lists but a different data type. user=> (type []) clojure.lang.PersistentVector user=> (type '()) ; gotta quote the list clojure.lang.PersistentList$EmptyList user=> (type {}) clojure.lang.PersistentArrayMap user=> (type #{}) clojure.lang.PersistentHashSet Different data types are used for different things. Vectors have more natural insertion behavior, so most people use them where that might happen. user=> (conj '(1) 2) (2 1) user=> (conj [1] 2) [1 2]
- tmtvl 3y agoThe example that most typifies my issues with Clojure syntax is let-binding. In Lisp it's very clearly structured: (let ((foo bar) baz (quux frob)) ...) In Clojure not only are the bindings unstructured, they are thrown into a vector. Not a list, not a map (for which Clojure has dedicated syntax, mind), a vector. (let [foo bar baz quux frob] ...) And that is one of the only two places I know of where Clojure arbitrarily uses a vector when it uses lists everywhere else: (defn foo [bar] ...) Instead of either of: (defn foo (bar) ...) [defn foo [bar] ...]