From: Sam S. <sd...@gn...> - 2017-12-21 17:15:00
|
Jörg, > * <Wbret-Plevy.Ubruyr@g-flfgrzf.pbz> [2017-12-21 16:45:16 +0000]: > > Your lazy-let reminds me of the trouble Pythonistas have with the > local/global variable dichotomy and the `global` statement. That made > it into the Python programming FAQ. IIRC, setting a variable first > defines it in the local environment; only reading one sees the global > environment. > https://docs.python.org/3/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python No, this is very different. The Python global/local problem is because the way a variable (first) _used_ affects how it works. My LAZY-LET merely separates initialization from binding. I.e., I allow code between binding and initialization to ignore the binding. The idea is to make the macroexpansion of loop behave the way people perceive loop to operate. (macroexpand '(loop ....)) looks like this: --8<---------------cut here---------------start------------->8--- (MACROLET ((LOOP-FINISH NIL (SYSTEM::LOOP-FINISH-ERROR))) (BLOCK NIL (LET ((...)) (PROGN (LET ((...)) (LET NIL (LET ((...)) (LET NIL (MACROLET ((LOOP-FINISH NIL '(GO SYSTEM::END-LOOP))) (TAGBODY (SETQ ...) SYSTEM::BEGIN-LOOP ....)))))))))) --8<---------------cut here---------------end--------------->8--- most of those LET outside of TAGBODY are _not_ supposed to initialize the variables they bind. > I believe the Python lesson clearly is to *not* re-invent that trouble > in Lisp. TAGLET is _not_ supposed to be a public interface, just an internal tool to implement LOOP. It closely corresponds to how people read LOOP, so it has the best chance to result in code doing what the user expects. -- Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1504 http://steingoldpsychology.com http://www.childpsy.net http://www.dhimmitude.org http://thereligionofpeace.com http://honestreporting.com http://jij.org Whom computers would destroy, they must first drive mad. |