[reformatting response for readability and giving Glenn a stiff talking
to]
Glenn Linderman <[EMAIL PROTECTED]> writes:
> Piers Cawley wrote:
>
>> Okay boys and girls, what does this print:
>>
>> my @aaa = qw/1 2 3/;
>> my @bbb = @aaa;
>>
>> try {
>>     print "$_\n";
>> }
>>
>> for @aaa; @bbb -> my $a; my $b {
>>     print "$a:$b";
>> }
>>
>> I'm guessing one of:
>> 1:1
>> 2:2
>> 3:3
>>
>> or a syntax error, complaining about something near
>> C<@bbb -> my $a ; my $b {>
>>
>> In other words, how does the parser distinguish between postfix for
>> followed by a semicolon, and the new semicolon enhanced 'normal' for?
>
> That particular example is flawed, because the try expression is turned
> into a try statement because the } stands alone on its line.
>
> But if you eliminate a couple newlines between } and for, then your
> question makes sense (but the code is not well structured, but hey, maybe
> you take out all the newlines for a one-liner...).
>
> The answer in that case is probably a syntax error, and to avoid it, you
> put a ; between the } and the for.

Yeah, that's sort of where I got to as well. But I just wanted to make
sure. I confess I'm somewhat wary of the ';' operator, especially
where it's 'unguarded' by brackets, and once I start programming in
Perl 6 then 

    for (@aaa ; @bbb -> $a; $b) { ... }

will be one of my personal style guidelines.

-- 
Piers

   "It is a truth universally acknowledged that a language in
    possession of a rich syntax must be in need of a rewrite."
         -- Jane Austen?

Reply via email to