Override operators with the scope just like functions
- Dominant language
- JavaScript
- Stars
- 15.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
> ```
> f(x,y) = (y==0) ? undefined : x%y; evaluate('mod(22,0)', {mod: f})\n evaluate('22 % 0', {mod: f})
> ```
>
> yields `[undefined, 22]`.
That is an interesting case. What happens right now is that functions and constants can be provided by the `scope` passed to `math.evaluate`, but this will not have effect on operators. I.e. passing `mod` or `add` or so to `scope` will not replace the operators `%` and `+` etc. It makes sense that they would.
_Originally posted by @josdejong in https://github.com/josdejong/mathjs/issues/2617#issuecomment-1189953880_
The purposeof this issue is to ~~discuss whether overriding `mod`, `add`, etc. in the scope should affect the outcome of infix operators like `%`, `+`, etc. (And if the conclusion is so,~~ serve as a marker that a PR to do this is needed.)
Contributor guide
Assessment
This issue has not been assessed yet.