John Porter wrote:
> 
> Randal L. Schwartz wrote:
> >
> > Yes, I'd be in favor of making return() in a valued block (as opposed
> > to a looping block) abort the block early and return the value.
> 
> Imho, it should return the value, but not abort the block.  That's
> not very dwimmy.  Loop blocks look like sub blocks to me.  After all,
> grep is (ostensibly) prototyped as grep(&@), so I expect to pass it
> a sub block.  And that block gets called once per iteration over the
> input list; "return" is what I expect it to do once per iteration,
> implicitly; so using C<return> explicitly to mean "no further iterations"
> is highly counterintuitive, or at least inconsistent.


What if we could use C<goto> to exit valued iterators? Currently we cannot
because labels can not appear within statements, only on their own.  
Allowing labels to appear anywhere -- that might initially be confusing, but
would it be impossible?


$ perl -le'goto two; one: print "one"; exit; two: print "two"; print  grep { ($_ == 25 
and goto one) or !($_ % 3) }
(1..30)'
two
one


$ perl -le'goto two; one: print "one"; exit; two: print "two"; print  three: grep { 
($_ == 25 and goto three) or !($_ %
3) } (1..30)'
syntax error at -e line 1, near "three:"
Execution of -e aborted due to compilation errors.


-- 
                          David Nicol 816.235.1187 [EMAIL PROTECTED]
           perl -e'map{sleep print$w[rand@w]}@w=<>' ~/nsmail/Inbox

Reply via email to