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
Given that operator association doesn't mean operator position, that expression is actually valid, maybe it's possible to add an "operator position" flag but it will actually create a fairly complex code for some really weird corner cases...
Question: Is there other "just unary" operator that uses postfix notation in an infix environment? (aside from factorial)
Currently unary operators like - and + don't fail because the tokenizer attempts to retrieve the binary operator, but if you comment lines 96, 97, 98 and 100 of Operators.class, an expression like 3- becomes -3.
Since I honestly can't think/find another operator that behaves like factorial, IMHO the simplest solution is to add ! as a builtin operator and special case it (for instance treat it like a binary operator, and insert an unused value as the second argument).
The only issue I can see (besides having an unused token) is that implicit multiplication operator won't be added (but actually fails now too).
Hmmm, I will have a think about that. I'm not in favour of adding it as a builtin operator and have some special handling for that, since it could happen with any user-defined unary operator.
The following expression gets evaluated although the factorial is in a nonsensical position:
This should throw an exception
The text was updated successfully, but these errors were encountered: