Skip to content

Override operators with the scope just like functions #2631

@gwhitney

Description

@gwhitney
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 #2617 (comment)

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions