develooper Front page | perl.perl6.language | Postings from May 2004

Re: C style conditional statements

Thread Previous | Thread Next
From:
Andrew Rodland
Date:
May 11, 2004 17:31
Subject:
Re: C style conditional statements
Message ID:
200405112031.55793.arodland@entermail.net
On Tuesday 11 May 2004 08:00 pm, Pedro Larroy wrote:
> 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?

My understanding is that it was mostly a /(counter)?cultural/ decision, to 
make dangling-else syndrome impossible. For the same reason "else if" is 
spelled "elsif", so there doesn't have to be a special braceless exception 
for "else".

It might also be wise to note that if your statement is really that simple and 
important, you might be better off writing "statement if condition".

Yes, I know that I'm diverting rather than strictly answering. My personal 
opinion is that I can live with it, because I've shot myself in that 
particular foot before, and that there are good reasons. My other opinion is 
that I wouldn't mind if a particular rule in the grammar could be enabled / 
disabled with "use strict 'braces'" either, as it is somewhat unperlish to 
prevent footshooting for that sake alone.

Cheers,
Andrew

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About