There are some cases where it would be convenient for the evaluation of a token to depend on the context it's evaluated in.
Examples:
946 - functions to format numbers should produce LaTeX when evaluated inside latex()
764 - replace number literals with decimal values inside decimal()
At the moment, when an argument of an operation is evaluated, it doesn't have any access to its parents in the expression tree.
I can think of two solutions, both of which require the context-changing operation to be lazily evaluated:
The parent could set a flag on the evaluation scope which the child checks when it's evaluated. This requires the child tokens to know how the parent wants the evaluation to change in response to the flag.
The parent operation could rewrite the tree before it's evaluated. This might require the parent to also know about any other context-changing operations lower down in the tree.
This might end up being related to #677 - parsers for different kinds of notation.
There are some cases where it would be convenient for the evaluation of a token to depend on the context it's evaluated in.
Examples:
946 - functions to format numbers should produce LaTeX when evaluated inside
latex()
764 - replace number literals with decimal values inside
decimal()
At the moment, when an argument of an operation is evaluated, it doesn't have any access to its parents in the expression tree.
I can think of two solutions, both of which require the context-changing operation to be lazily evaluated:
This might end up being related to #677 - parsers for different kinds of notation.