develooper Front page | perl.perl6.internals | Postings from July 2002

Re: Perl6 grammar (take V)

Thread Previous | Thread Next
Aaron Sherman
July 12, 2002 10:57
Re: Perl6 grammar (take V)
Message ID:
On Fri, 2002-07-12 at 02:33, Sean O'Rourke wrote:

> What's currently "supported":

> - if/elsif/else (even "unless" and the feared "elsunless";)

When we talked about this last, I had been concerned about loops and
conditionals, but others had scoping concerns. Ok, perhaps there's no
way we can roll in loops (though that seems wrong to me), but please
don't do THIS.

There's really no good reason to continue treating conditionals this
way. A simple

    cond: ('if'|'unless') expr block [ 'else' (cond|block) ]
solves the whole thing; is easy to write and parse; and reduces the
number of keywords in Perl. Could it be a better option if you added
whipped cream and a cherry?! This never gets as ugly as C because the
only tokens that can follow 'else' are 'if' 'unless' and '{'... no

Now, for those who will freak out, you could preserve "elsif" as a
deprecated form, but I'd at least say that it should generate a
compatibility warning so that it's fair game for later removal.

An example:

    $pid = fork() // -1;
    if $pid < 0 {
    	# error ...
    } else unless $pid {
    	# Parent
    } else if $pid > 0 {
    	# Child
    } else {
    	# Huh? Can't happen

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About