Re: Why doesn't foreach return a value



tom.rmadilo wrote:
Foreach actually never 'goes away', so how could it return?

Of course it returns, like every other command does. (Well, except infinite loops.) What do you mean "goes away"?

Is it called as a function, or is is simply used in the current flow of code?

It's called as a function, as is every other command in Tcl, including proc, while, if, and so on.

I doubt you will find any logical support for anything in particular.

Returning either the second argument or the final value of the first argument or the length of the second argument might all be useful. But these are all things that are trivial to get in other ways.

If "break" was changed to take an argument, returning the value passed to break might be interesting. But again, I expect this can already be done with clever use of [return].

The most obviously useful information would be some kind of metadata
which documents what happened, mostly for the case of continuing,

Continuing what? The loop runs until it exits, at which point you don't continue it.

maybe what state the loop was in upon exit.

What do you mean? What state do you not get when you exit?

--
Darren New / San Diego, CA, USA (PST)
On what day did God create the body thetans?
.



Relevant Pages

  • Re: How can I do this?
    ... I know I can use wait in a shell script to monitor whether a command ... invoked within that shell script exits. ... a1 has pid 10023 ... Now how can I create a mechanism (either one line command, ...
    (comp.unix.shell)
  • Re: FC5 system() call
    ... What happens if you issue the command directly from the ... Use this as a suggestion to apply the information from errno ... The child then exits and the system call then returns the exit ...
    (Fedora)
  • Re: Monitor use of Load-Library as JOBLIB/STEPLIB
    ... I executed the display ... about a subset of fetched modules in the library, ... This library contains JES2 Exits, Command Exit, SMF Exits, FLPA module, ...
    (bit.listserv.ibm-main)
  • Re: $SYNCHRONIZE ... why isnt $STATUS the $STATUS from the batch job?
    ... code then deliberately sets that bit so that when *it* exits with the same ... There is no other way of distinguishing messages from the command itself, ... Although one might argue for an additional qualifier on SYNCHRONIZE to force ...
    (comp.os.vms)
  • Re: Spooky
    ... San Diego is a MAJOR US Navy port and command center for the Pacific ...
    (rec.arts.sf.tv.babylon5.moderated)