Re: [clisp:bugs] #375 loop (...) for vars on vars misbehaving

<[email protected]>
Newsgroups gmane.lisp.clisp.devel
Message-ID <f2cf7f62a8304f1ca49f294117d49bc3@HE105658.emea1.cds.t-internal.com>
Sam,

My 2005 query "loop variable value in finally forms?" to comp.lang.lisp produced nothing, alas:
https://groups.google.com/forum/#!msg/comp.lang.lisp/VC4fWvqt3y8/yvLNZF7cIQwJ;context-place=topic/comp.lang.lisp/Z7VtKCZ3xkQ

Generally, I feel Barry Margolin is right in the response to your query:
https://groups.google.com/forum/#!topic/comp.lang.lisp/U5LqiM5nKq8

In my example as well, the value within finally depends on whether the user-visible variable was assigned, then tested, or whether some internal variable was assigned, then tested, inside each iteration, such that the assignment of the user-visible variable is skipped when the test causes the iteration to terminate.


One could make the case that values are not available within the epilogue(!), as follows:
6.1.2.2 http://clhs.lisp.se/Body/06_abb.htm
"When a loop form is executed, the local variables are bound and are initialized to some value.
These local variables exist until loop iteration terminates, at which point they cease to exist."

6.1.1.4 http://clhs.lisp.se/Body/06_aad.htm
"Loop epilogue
    The loop epilogue contains forms that are executed after iteration terminates, such as finally clauses [...]"

Unambiguously, the local variables do not exist anymore within the epilogue!
Of course, that renders many examples of COLLECT INTO useless.

One might argue what "local variables" are, however
6.1.2.2
"The with construct initializes variables that are local to a loop."
Clearly, WITH variables are unavailable within FINALLY. Ouch. Fun.


About clisp, we shall ask ourselves whether we want clisp's loop to assign the user-visible variables prior to the test, and document when that's applicable:
+ FOR x ON ; x a symbol, not nil, no destructuring
+ FOR-AS arithmetic (as I argued elsewhere)

- FOR ... IN list ; might retain the last iteration's value, if any
- FOR ... ACROSS, likewise
- FOR ... HASH, likewise
- FOR s PACKAGE ; -- assign s to NIL at end, saving the internal "SYMBOL-" variable?

o FOR-AS = THEN ; -- "does not provide any termination test."


That's not all there's to document. The next is whether to document whether termination tests are combined or not, esp. in FOR AND FOR. That also influences the values available in FINALLY.
See another mail.

Regards,
	Jörg
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.