Mark Mielke wrote:
>What's the value of this, "given" that do{} exists today?
do{} ends with a closing brace, which looks more like the end of
a compound statement than the end of an expression. eval{} has the
same problem. It's syntactically preferable for an expression to end
with something that "looks like" it ought to be followed by a semicolon
or infix operator. Parens (which would be my first choice for looking
expressionish) are unavailable, because parens (and multiple parens)
following "if" et al already have meaning.
Also, the extra keyword "do" of do{} draws unwarranted attention to the
process of embedding a compound statement in an expression. We want
the main attention to be on the structure of the statement itself.
>If you must introduce new syntax, I'd suggest something like GCC's ({
>... }). The () clearly suggests it is an expression.
Would be nice, except that {...} already has meaning in an expression
context, as a hash constructor. Step away from the ambiguity. However,
that problem doesn't apply to keyword-headed compound statements.
You could do
NEW SYNTAX EQUIVALENT TO
(if($a < b) { ... }) do { if($a < $b) { ... } }
and the same for "while", "given", et al. A substantial downside is
that you then have expressions of the form "(...)" where the "..." is not
itself an expression. Editing errors are inevitable. It's also rather
unlike existing Perl syntax in that the controlling keyword is contained
within the bracketing punctuation, rather than coming first as usual.
-zefram
Thread Previous
|
Thread Next