coffee wrote:If you use that second example and wrap msgbox as a function, the ! in the next line does not get appended to the string, but kind of like to the msgbox function call and the next call below continues normally.
Why would something
outside the parentheses get appended to one of the function's parameters? Of course it wouldn't. Would you expect x in
MsgBox(y) x to appear in the MsgBox?
MsgBox("foo") !x ? y : z may have the right effect, but it is encountering a silent (in v1) error condition every time.
0 !1 does not perform auto-concat. The reasons for this can be found in the source code:
Code: Select all
// If what lies to its left is a CPARAN or OPERAND, SYM_CONCAT is not auto-inserted because:
// 1) Allows ! and ~ to potentially be overloaded to become binary and unary operators in the future.
// 2) Keeps the behavior consistent with unary minus, which could never auto-concat since it would
// always be seen as the binary subtract operator in such cases.
// 3) Simplifies the code.
0 !1 pushes two values onto the stack, performs "NOT", and then finishes the expression with too many values on the stack. This is treated as an error (because it is invariably the result of a syntax error) and the expression yields a blank result.
MsgBox % 0 !1 (optionally with a line break before "!") therefore shows blank.
MsgBox("foo") !x ? y : z is the same, but MsgBox is called as part of the expression and therefore before the error condition is encountered.