From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> 
> Garrett Goebel <[EMAIL PROTECTED]> writes:
> >
> > I agree... why can't a block be a block? Or put another
> > way, instead of trying to shoehorn in something new, why
> > don't we take away something old and treat all the blocks
> > the same under Perl 6?
> 
> You mean this would no longer work?
> 
>     while (<>) {
>       if ($some_condition) {
>         fred fred fred;
>         next;
>       }
>       barney barney barney;
>     }

With my current proposal, you're right... if you wrote that in Perl 6, it
wouldn't work the way you're wanting...

So yes... this is starting to feel a little bit more like a shoehorn. Can I
extricate myself by wedging one more thing in?

When you call C<next>, C<last>, or C<redo> without an explicit label, then
it defaults per current behaviour to the nearest loop block. So if you wish
to short-circuit a code block or a bare block... they'd have to be labelled
and short-circuited explicitly.

> Nope, I think we need a distinction between "looping" blocks and
> "non-looping" blocks.  And further, it still makes sense to
> distinguish "blocks that return values" (like subroutines and map/grep
> blocks) from either of those.  But I'll need further time to process
> your proposal to see the counterarguments now.

Yes... loop blocks are special in that short-circuiting the looping block
short-circuits the loop, not just the block. Perhaps we could maintain that
as the default behaviour but otherwise blur the line by allowing all blocks
to C<return>, C<yield>, C<next>, C<last>, C<redo>, and return last values?

I'm not sure why we need to distinguish blocks that return values from those
that don't. But I'm not nearly as experienced or knowledgible about these
things as 99% of the people on this list. And I have a harder time seeing
the impact of my suggestions.

What is the difference between a block returning a value in a void context,
and one that doesn't? I suppose this introduces a new way to create runtime
exceptions by short-circuiting a subroutine without returning a value when
that subroutine is being used to provide a value for an lvalue assignment.

I would also like to thank everyone for their patience and civility when
responding to my posts. I'm trying to read up and get a better grasp of the
fine details... but I'm still learning a lot as I go. And I'm a lot further
back on the path to Perl enlightenment than most here. When it appears I'm
off in left field... I probably am ;)  In such cases, please take the time
to kindly nudge me back in the direction of reality.

Garrett

Reply via email to