Me wrote:

> > "given nothing...":
> >
> >     given () { ... }
> 
>     do  { ... }
> 
> seems simpler.

But doesn't have the same effect. A C<when> inside a C<do> responds to
the current value of the "subject" specified by any surrounding
topicalizer (i.e. C<given>, C<for>, C<sub>, etc.)


> 
> > Suppose you want to preserve $_ and alias
> >
> >    given $value -> $g {
> 
> '->' seems more visually noisy than it need be in this case.
>
> Perhaps:
> 
>     given $value as $g { ... }
> 
>     for @foo as $f { ... }
> 
> But, I can see how
> 
> >     for 0 .. Inf; "a" .. "z" x 1000 -> $i; $a {
> 
>     for 0 .. Inf; "a" .. "z" x 1000 as $i; $a {
> 
> would be seen as a counterexample by some.

Yep. By Larry, for one. And me, for another. ;-)

        
> > KEEP blocks would only be executed if the block succeeded.
> > UNDO blocks would only be executed if the block failed.
> 
> What defines success? I sometimes raise exceptions to signal
> that I'm done, with success, and it's time to wrap up and go back
> to some calling code several levels up the stack. But I guess this
> is an unusual case so not being able to use KEEP and UNDO
> as intended is OK.

Just derive your "successful exception" from Control:: rather that
Error:: (or whatever the final standard names are).

> Or maybe each block has a Success class exception object
> associated with it unless a different exception is raised, and
> KEEP is called if the exception isa(Success). Then I can raise
> a subclass of Success.

Yep. Just s/Success/Control or whatever Larry decides/

Damian


Reply via email to