Re: Why doesn't foreach return a value
- From: "tom.rmadilo" <tom.rmadilo@xxxxxxxxx>
- Date: Thu, 31 Jan 2008 00:34:43 -0800 (PST)
On Jan 30, 9:04 pm, Darren New <d...@xxxxxxxxxx> wrote:
tom.rmadilo wrote:
Call 'return' inside a loop and you will discover the difference
between a function/proc and a foreach loop. Foreach doesn't 'go away',
because the foreach body is executed in the current context.
I have no idea what you think "go away" means there. I know the
difference between a proc and foreach. Call [break] inside a proc and
the proc doesn't "go away" either. Call [error] and both the proc and
the foreach it's in "go away".
You make a good point here. The boundaries of loops and stack levels/
procs are not the same. Where exactly code will resume execution when
interrupted by [break], [continue], [return] or [error] depends on
more than just the command.
By "go away", I only mean that the current context "calls" a command.
A typical proc body isn't executed in the context in which it is
called, it "goes away", and then "returns".
.
- Follow-Ups:
- Re: Why doesn't foreach return a value
- From: suchenwi
- Re: Why doesn't foreach return a value
- References:
- Re: Why doesn't foreach return a value
- From: Rufus V. Smith
- Re: Why doesn't foreach return a value
- From: Mark Janssen
- Re: Why doesn't foreach return a value
- From: tom.rmadilo
- Re: Why doesn't foreach return a value
- From: Darren New
- Re: Why doesn't foreach return a value
- From: tom.rmadilo
- Re: Why doesn't foreach return a value
- From: Darren New
- Re: Why doesn't foreach return a value
- Prev by Date: Re: Why doesn't foreach return a value
- Next by Date: Re: Why doesn't foreach return a value
- 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
|