On Fri, Apr 12, 2002 at 04:00:37PM +0100, Piers Cawley wrote:
> <X-posting to perl6-language>
> [EMAIL PROTECTED] writes:
> > As for "cleanness", this is my interpretation of how perl6 is going
> > to work:
> >
> >     %foo = ();
> >     if %foo {"key"} {print "Hello 1"}
> >     ####
> >     %foo = ();
> >     if %foo{"key"} {print "Hello 2"}
> >     ####
> >     %foo = ();
> >     if %foo{"key"}{print "Hello 3"}
> >
> > Case 1 will print "Hello 1"; this is a block after the if statement.
> 
> No, it will be a syntax error. The first closing brace does not end
> the statement, probably something like "Block seen when keyword
> expected". 

Now I am confused. In perl6, we can leave off the the parenthesis
around a condition, and I hope that it isn't required to have
an 'elsif' or 'else' block.

Why isn't

    if %foo {"key"} {print "Hello 1"}

equivalent with the perl5 syntax:

    if (%foo) {"key"} {print "Hello 1"}

Which keyword is it expecting?

> > Case 2 will not print anything. The print is in the 'then' part
> >        of the if.
> 
> Correct.
> 
> > Case 3 will be a syntax error - an if statement with a condition,
> >        but not block.
> 
> It won't be a syntax error *yet*. If there's a block immediately
> following then that will be treated as the 'then' block. If it's the
> end of file, or a nonblock, then it'll be a syntax error.

Did the code show anything following it? No? Well, then assume
it isn't there. ;-)

Next time I'll show this to someone, I'll add a semicolon.



Abigail

Reply via email to