continueonly and do not allow
Only those 3 should be supported in
if x, y(), return z, everything else must be an expression.
jethrow wrote:lexikos wrote:I really doubt that it's about there being less typing, either way.
I agree. I'm gonna go out on a limb & say it's because of the restrictions on how you can write your syntax (not un-similar to complaints against python). I don't want to add another line to my code - I want the simple condition & action on the same line - especially if I'm in a One-Liner type of mood. This becomes extremely important when I'm trying to write beautiful, condensed code - or just trying to impress others with my sophisticated coding skills.
... of course I'm being sarcastic, yet truthful ...
Anyways, I'm gonna jump the gun & say why not take the perl approach and allow:
lexikos wrote:Implementing the following is trivial:It is less trivial to intuitively group the statements, as in
if x, y(), return zgrouping the last two in a block (or likewise when below an if/loop/etc.).
x := 1, y = 2allowing = to assign an expression.
if x, y(), return zwas interpreted as
expression, statement, which would be one way of allowing
if condition, expression, else, statement. Obviously, the others could be allowed without this.
expression, statementbut not
SomeCommand, % expression, statementcould be another source of confusion. Allowing the latter - with restrictions like "must be after the last parameter of the command" - would create more complication (harder to understand, remember, implement...).
if (x) y(); return z;does not belong to the if, but in those languages, the semicolon is clearly a statement separator, never used to delimit parameters or sub-expressions. In AutoHotkey,
y(), z()works just fine because
y(), z()is a single expression with the comma ("multi-statement") operator. But if
expression, statementwas allowed and simply treated as two separate lines (no block/grouping), either
y(), return z()and
y(), z()would be inconsistent, or worse,
if x, y(), z()would be interpreted as
catch, var, statementwould create another source of confusion, because someone is bound to write something like
catch, return, where return is a variable intended as a statement.
action1, action2 ;same-line 2 actions
if(expressinon1, expression2, action1, action2)
"" ; the action
expression2, action1, action2 ;same-line 3 actions
Users browsing this forum: No registered users and 3 guests