Leaving out considered dangerous
A knowledge seeker asked us why a loop spec allows $i>10
but not $i<10
. The reason is that the postcircumfix:«< >»
changes the grammar in such a way that it expects a list quote after the $i
. As a result you get the following.
loop (my $i=0;$i<10;$i++) {}; # OUTPUT«===SORRY!=== Error while compiling Whitespace required before < operatorat :1------> loop (my $i=0;$i<10;$i++) {};⏏ expecting any of: postfix»
I tried to illustrate the problem by making the $i>10
case fail as well by defining a new operator.
sub postcircumfix:«> <»($a){}; loop (my $i=0;$i>10;$i++) {}; # OUTPUT«===SORRY!=== Error while compiling Unable to parse expression in postcircumfix:sym«> <»; couldn't find final $stopper at :1------> rcumfix:«> <»($a){}; loop (my $i=0;$i>10⏏;$i++) {}; expecting any of: s…»
I concluded with the wisdom that that Perl 6 is a dynamic dynamic language. While filing a related bug report I made the new years resolution to put a white space around each and every operator. You may want to do the same.
Categories: Perl6, Uncategorized
Comments (0)
Trackbacks (1)
Leave a comment
Trackback
-
January 9, 2017 at 23:062017.02 Dogfooding and Powerbotting | Weekly changes in and around Perl 6