Hacker News new | ask | show | jobs
by BoingBoomTschak 13 days ago
> The seq abstraction, for example, means I usually don’t have to worry about what kind of sequence I’m dealing with

Eh? That's completely lifted from CL (https://www.lispworks.com/documentation/HyperSpec/Body/t_seq...). Same for AREF/NTH, there's ELT.

Other than that, I agree, CL is baroque yet needs some hole filling here and there.

> Lisp: everything is a list

But that's wrong. Not even a little. Unless you mean LISP 1.5...

> Too much syntax

Funnily, I'm mostly okay with the new vector/set/hash-table literals, my big problem and that of some other people is the use of vectors in macros/special operators instead of lists. `(let [a b] ...)` instead of `(let (a b) ...)` is _not_ okay.

3 comments

> Eh? That's completely lifted from CL.

Clojure’s abstraction is a bit more far-reaching than Common Lisp’s SEQUENCE, implemented as interfaces rather than types.

A Clojure sequence is anything “seqable” (either implements the Seqable interface, or special case handling for host platform collections), not just lists and vectors. Hash maps, sets, Java Iterables, etc. are all seqable and work with the same standard collection functions.

e.g. you can `(map (fn [[k v]] …) {:a 1 :b 2})`, rather than needing a separate MAPHASH function.

> `(let [a b] ...)` instead of `(let (a b) ...)` is _not_ okay

it is however quite consistent, clojure uses vector form for most macros that require a "control" form before a "data" form: argument list in defn, names list in let, iteration descriptors in for, etc. you get used to consistency quite easily.

I haven’t used clojure in quite a while but what’s the issue with (let [a b] …)?

Is (let (a b) …) even valid clojure?

In CL and Scheme, it's (let ((var1 val) (var2 val)) body...). So parentheses are used for grouping and function/macro application. In Clojure, parens are just used for application, so you have e.g. (let [var1 val var2 val] body...), or (defn foo [x] ..) or (cond testa 1 testb 2 ...).

It takes some getting used to, and I do wish Clojure would do something more like (let [[var1 val] [var2 val]] ... .. though of course then you'd have to figure something else out for destructuring.

I believe it would be (let ‘(a b)), but I’m not sure if that’s valid or not. That’s how Racket does its version of defn