Closed gilch closed 5 years ago
Let has a bindings part and a body part. Scheme wraps the bindings part. Arc just has one binding, so no wrapping is required. With unpacking, maybe that's all we need. This makes it clear that it's let
, and not let*
.
!let: [1, 2]
:,: foo bar
frobnicate: foo bar
Or we could wrap the body part instead. Call it in
like Haskell. This syntax could have let*
semantics, which might be an important capability.
!let:
foo 1
bar 2
:in: frobnicate: foo bar
Or we could assume the last expression is the body, and require an explicit !begin
. Most of the statement macros haven't required this though.
How should it look in Hebigo? In Scheme it's like
The same structure wrritten in Hebigo would be
That doesn't look too bad, but I'd prefer to avoid using
pass:
. We could use a meaningful control word with arguments instead.Arc Lisp's
let
only binds one name.This looks a lot cleaner, until you have to start nesting them.
Still not that bad when there's only two, but indents can add up fast. I'd like to flatten them for the same reason we have
elif
in Python. Arc haswith
for this.With multiple variables, there's also
let*
andletrec
variants to consider.letrec
looks hard without mutation. Clojure doesn't have it, but hasletfn
instead. But at that point you might just want a class.Clojure has a powerful recursive destructuring syntax built into its let. Even with one binding pair, you could still bind multiple variables this way. Python has sequence destructuring only, but requires statements to do it. An example like
Might look like
It's not so pretty without the brackets. With more meaningful control words,
More Clojurelike options