Austin Hastings writes: > > > > -----Original Message----- > > From: Adam Turoff [mailto:[EMAIL PROTECTED] > > On Tue, Nov 25, 2003 at 01:03:19PM +1100, Damian Conway wrote: > > > Schwern observed: > > > > Perhaps this is yet another argument for insisting on: > > > > > > while do {$n++; $foo > $bar} > > > > > > instead. > > > > That looks like syntactic sugar for > > > > while (do) {$n++; $foo > $bar} > > > > and could be interpreted as either: > > > > while "do" {...} ## perl5 bareword > > while do() {...} > > > > Luke's "then" feels like the best fit on the one hand, and the worst fit > > on the other. Everything else feels worse, though. > > Hmm. Why not just explicitly allow semicolon when surrounded by parens? > > while ($n++; $foo > $bar) {...}
Well, because the intent of the original proposal was to "fatten up" the C comma to make it explicit, easy to see, and clearly unambiguous. A semicolon does none of these things. It also, as you mention, prevents the compiler from catching a rather common syntax error. But other than that, uh, sure. Providing we spell parens C< do{} >. :-) > Removing the parens changes the results, which is just what you'd expect > mathematically. > > $f = (0, 1, 2, $n++, $foo > $bar); # List > > $f = (0; 1; 2; $n++; $foo > $bar); # Sequence of statements, three > useless. > > "C" style C<for> loops then look like: > > for (($a = 0; $b = $num_elts); $a < @arry; ($a++; $b -= $offset)) {...} By which you mean loop ($a = 0; $b = $num_elts); $a < @arry; ($a++; $b -= $offset) {...} right? Perhaps my favorite syntactic thing Perl 6 has done so far is gotten rid of those dastardly parens on control constructs! Yay! Luke > > Which is on the one hand yucky, but on the other hand very explicit. > > (I suppose I could propose using semicolon for the list separator, but that > would drive the syntax-highlighters insane, and I like syntax-highlighting.) > > =Austin > > PS: An immediate drawback that occurs to me is that of catching unbalanced > parens -- when the statement terminator is a valid sequence delimiter, all > the rest of the code looks like a sequence. But the first nesting closing > brace would probably catch that. >