Re: Why doesn't foreach return a value
- From: Fredderic <my-name-here@xxxxxxxxxx>
- Date: Fri, 1 Feb 2008 19:17:03 +1000
On Thu, 31 Jan 2008 08:01:33 -0800 (PST),
"tom.rmadilo" <tom.rmadilo@xxxxxxxxx> wrote:
Starting at line 1811 of generic/tclCmdAH.c:[snip]
This executes the body code of foreach (in the parent frame) and
either breaks or continues, after resetting the result code to TCL_OK.
Once out of this loop (not shown), the next code nullifies the Tcl
result.
But I think I made a mistake about one thing in a previous post. The
loop code/frame/level doesn't cross the boundary of a proc. If you use
a bare [break] or [continue], you get an error. But, if you use
[return -code break/continue],
you can get out of the current level and then out of the loop.
My, I think there might be hope yet. ;)
You should be able to see that it does indeed receive a value
returned. Now, if you trace that back to figure out where those
TCL_BREAK and TCL_CONTINUE values came from, you'll figure it all out.
The mistake you've made all through this thread, is that the proc isn't
the only boundary to be aware of. Individual commands have their own
boundaries, none of which are violated. Short of a setjump/longjump,
there's really very few other options, and most of them are variants of
the same theme, and very obviously non-regular returns.
[return], [continue], or [break], all send a signal back indicating
special action needs to be taken. Each level in turn, then either
handles that signal or passes it back. This signal, which includes an
"all okay, go get the result" variant, is "returned".
Fredderic
.
- Follow-Ups:
- Re: Why doesn't foreach return a value
- From: tom.rmadilo
- Re: Why doesn't foreach return a value
- Prev by Date: Re: Why doesn't foreach return a value
- Next by Date: Re: Dpi and Resolution issues
- Previous by thread: Re: Why doesn't foreach return a value
- Next by thread: Re: Why doesn't foreach return a value
- Index(es):
Relevant Pages
|
|