Le Wed, May 12, 2004 at 02:00:42AM +0200, le valeureux mongueur Pedro Larroy a dit:
> Hi
> 
> Is there any chance that in perl6 there will be the possibility to write
> if/else statements without {}s with the condition at the beginning?
> 
> Like 
> 
> if (condition)
>       statement;
> 
> In order not to break traditional C culture. Is there any technical
> reason why it wasn't done in perl5? 

In Perl5, variable declaration are an executable statement. Also the
scope of a variable starts from its declaration and ends at the
end of the immediately enclosing block. Things would get
problematic if the branches of an if/else were not scoped.
What would be the meaning of :

if (condition)
   my $foo = 'bar';
else
   print $foo;

Now about  the syntax, it is not clear if the statement before
the 'else' can/must be semicolon terminated.

A similar example of stange meshing of scope and flow of control in
perl5 is:

   my $foo = $bar if $buz;

I can't even remember what it supposed to do when it is in a loop
where $bar and $buz change. And I would bet that the exact
semantic is not even documented in most books.

--
 stef


> 
> Regards.
> 
> -- 
> Pedro Larroy Tovar | Linux & Network consultant |  piotr%member.fsf.org 
> 
> Software patents are a threat to innovation in Europe please check: 
>       http://www.eurolinux.org/     

Reply via email to