Re:The idiot's guide to special variables and lexical closur...
by thesmallestcat on Saturday July 22, 2017 @08:12PM
(#14830152)
What are the practical differences between special vars in Lisp and dynamic vars in Clojure? The obvious ones are that `def ^:dynamic` can't be local to a function, and that Clojure uses a separate form, `binding`, rather than `let`, to set their values.
[ Parent
| on HN ]
Re:The idiot's guide to special variables and lexical closur...
by AlainPicard on Saturday July 22, 2017 @08:42PM
(#14830276)
For me the largest difference is that Clojure carries
over all your dynamic bindings when creating new
threads (via 'future') and in lazy seqs, whereas
Common Lisp (typically) does not. I now understand
why they choose to do it this way, but I wish the documentation was much clearer in this regards.
Re:The idiot's guide to special variables and lexical closur...
by lisper on Saturday July 22, 2017 @08:51PM
(#14830303)
The CL standard doesn't deal with threads at all, so different implementations do things differently. But typically the user can control what the initial bindings of a thread are through keyword arguments to whatever function spawns threads.
Re:The idiot's guide to special variables and lexical closur...
by kazinator on Sunday July 23, 2017 @10:37AM
(#14832431)
I made a dialect once called VoqLisp in which a thread carried the dynamic bindings visible in the code which spawned it.
This then resembled POSIX environment variables: "FOO=bar command arg" and was handy in a similar way. You could use let to set up a bunch of parameters affecting the thread, and then create it in that body.
Re:The idiot's guide to special variables and lexical closur...
by kazinator on Saturday July 22, 2017 @08:27PM
(#14830215)
ANSI CL in fact uses the term "dynamic variable". The "special" aspect of a d. v. is the marking of a symbol itself for binding dynamically, rather than lexically. I.e. special treatment applies to it.