10 ms·
(lets a 1 b 2 (+ a b)) is such a nice macro. Everything but the last expression are bindings.
by sillysaurusx 6y ago
(lets a 1 b 2 (+ a b)) is such a nice macro. Everything but the last expression are bindings.
- TylerE 6y agoWhy is it nicer than (+ 1 2). What is gained from an extra layer of indirection?
- sillysaurusx 6y agoFewer parens. It was just a trivial example to illustrate the macro. (lets (a b) (list 1 2) c (+ a 3) (d e f) (some-func a b c) (* d e f)) It destructures automatically. The equivalent traditional macro might look like (destructuring-bind* [[(a b) (list 1 2)] [c (+ a 3)] [(d e f) (some-func a b c)]] (* d e f)) which is unreadable. And yeah, normally it's indented properly and yada-yada, and people use editor plugins like paredit to make it not such a pain to type, but still. It adds up.
- bjoli 6y agoWhat? The let way of variable bindings is standard just about everywhere. Why replace it with something that doesn't visually distinguish binding pairs? To my lispy eyes it is harder to navigate than (let ((a 1) (b 2)) (+ a b)) and harder to implement as a syntax rules macro :)
- sillysaurusx 6y agoFree yourself from the shackles of parens. Throw off your bindings and run into the streets. It's worth it. Arc uses (let a 1 (+ a 2)), and lets is simply the logical progression of that.
- bjoli 6y agoI have gone the other way. when I first learned macros I spent loads of time trying to make paren-free versions of the standard scheme forms, and now I can't even be assed to do the racketism of surrounding my binding clauses with []. The parens of let lets me easily distinguish the binding clauses, and lets me navigate it a lot easier in Emacs. The lets macro seems like the opposite of that. Every odd thing except the last element is an identifier and every even thing is that identifiers value.