- @guest3456: -1 to the syntax or -1 to the principle?
- smarq8: I think the idea is great, the main issues are: what syntax to use (what operator e.g. a symbol or 'then') and whether it's possible to handle break/continue/return (e.g. as functions, or whether AHK could run a text macro internally).
- AFAIK C++ rigidly requires the condition be within parentheses, thus such syntax is possible in C++, with AHK the syntax on an if line is more flexible so probably an operator would be the best solution (so that AHK would know that the if statement had ended).
- For reference, here are some current workaround ideas:
Code: Select all
;SCENARIO 1
(test) && msgbox()
(test) ? msgbox() : 0
;SCENARIO 2
(text) && exit()
(text) ? exit() : 0
ret := 0
(text) && (ret := 1)
(text) ? (ret := 1) : 0
;lower down after multiple 'if' one-liners
if ret
return ret
;also: a big ternary operator could be used
;SCENARIO 3
(test) && (func1(), func2(), func3(), exit())
(test) ? (func1(), func2(), func3(), exit()) : 0
if (test)
return format(retstr, func1(), func2(), func3())
if (test)
return format("", func1(), func2(), func3()) retstr
if (test)
return format(retnum, func1(), func2(), func3())
if (test)
return format(0, func1(), func2(), func3()) + retnum
ret := 0
(test) ? (func1(), func2(), func3(), ret := 1) : 0
(test) && (func1(), func2(), func3(), ret := 1)
;lower down after multiple 'if' one-liners
if ret
return