Closed Himmelt closed 9 months ago
Hello. --
operator, in modern languages is decrement operator.
i = 42;
--i;
# i == 41
but in math it is meanless
--42 == 42
There is not practical reason to write -- expr
, but if it is allowed - it is quite confusing for Nfun.
For example we have expression y == --x
it could be:
y = x # mathematical style. x == --x
or:
y = x-1 #immutable style
or
x = x-1 # C-like style
y = x
so we have disadavantage because of ambiguity, and no benefits. That is why Nfun does not support it
If for some reason you want to write -- math operator, that you can write it like this:
a = -(-(42) # a== 42
Was current behavior of nfun confusing for you? Should i deny this operator with detail error message to explain why it is prohibited ?
Thanks for your explanation, I will use -(-42) instead.
@Himmelt If it doesn't bother you, could you please tell me an example in which it is necessary to use -(-42) ? I am asking, because i need to understand different and unexpected for me scenarios.
@Himmelt If it doesn't bother you, could you please tell me an example in which it is necessary to use -(-42) ? I am asking, because i need to understand different and unexpected for me scenarios.
@tmteam I use Nfun for simple mathematic calculation (calculator),and the expression is the output of other modules. Before output, some strings (as the variables) will be replaced by the actual value, some values are negative, if the expression is "-\<xxx>" and "\<xxx>" is replaced by "-42" , the expression will be "--42".
I think you can set an option to switch mathematic calculator mode and advanced evaluator mode. What do you think ?
In my case, I just want a programable calculator library, and I found an opensource application named speedcrunch , it works fine but no donet library. Maybe it can help you to improve NFun ?
When I try to calc "--55" cause this exception. The result is expected to be "55". How can I use "--" ?