On Fri, 2005-04-15 at 13:10, Luke Palmer wrote:
> Aaron Sherman writes:
> > Among the various ways of declaring variables, will Perl 6 have a way to
> > say, "this variable is highly temporary, and may be re-declared within
> > the same scope, or in a nested scope without concern"? I often find
> > myself doing:
> > 
> >     my $sql = q{...};
> >     ...do some DB stuff...
> >     my $sql = q{...};
> >     ...do more DB stuff...
> 
> There's a pretty common idiom for this:
> 
>     {
>         my $sql = q{...};
>         # ... do some DB stuff ...
>     }
>     {
>         my $sql = q{...};
>         # ... do more DB stuff ...
>     }
> 
> You see it in test suites all over the CPANdom.  

You see it all over my code too... it is always possible to simulate
many kinds of trickery that way. For example, if you want to write a
loop with a counter that is visible one statement after the loop
completes, you can say:

        {
                my int $i;
                loop $i=0;...;$i++ {
                        ...
                }
                do_stuff($i);
        }

But isn't:

        loop my int $i=0;...;$i++ {
                ...;
                LAST{do_stuff($i)}
        }

much cleaner? I think so, if for no other reason than it explicitly says
what it means. That's one of the reasons that LAST is so handy.

So too would my mythical declarator would prevent a few steps that are
otherwise quite easy, but cumbersome in the large.

Whatever, though. It was a simple suggestion, and seems to have sparked
FAR more controversy than the small win warrants.

-- 
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback


Reply via email to