You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As for fixing it, this is a subtle issue. One thing that's clear is that users can't *set a variable directly to a negative value, because this line:
*set num -15
already means "subtract 15 from num", not "set num to negative 15."
We could put some special-case code in *temp to allow negative values, but I think it would be difficult to explain why *temp num -15 behaves so differently from *set num -15.
Ah, that's a good point; I had forgotten how the overloaded *set would interact with the whitespace-lenient basic math operators like - in this case. Good thing I'd always initialized negative values at 0 first...
I'm surprised *temp num 0-1 works. I hadn't thought calculations could be done in any statement without parentheses. Regardless, this workaround isn't valid for *create statements.
Proposed syntax:
*create num (-1)
and
*temp num (-1)
Parentheses are currently illegal in *set and *create statements, so I don't believe this should break existing code.
(I'd like to see *set num (-1) allowed, as well. Parallelism, for one thing, but I also find this syntax is more clear and readable than (0-1).)
*create test -5 and *temp num -5 each result in errors.
yields
(and that error message duplicates the word "a"); also
yields
The text was updated successfully, but these errors were encountered: