How about using tagged template literals for evaluating expressions? #3506
mrft
started this conversation in
Design decisions
Replies: 1 comment 2 replies
-
|
Template literals be really useful indeed. We've discussed it in #3393 (includes a working example too). |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Inspired by things like lit-html and uhtml, where you can simply write:
and realizing that mathjs already supports compiled expressions with
const expr = math.compile(...)andconst result = expr.evaluate(scope)I thought, why don't we simply allow to write things like:
which stays as close as possible to a mathematical notation while inlining the variable names directly in the formula.
More info about tagged templates
I wrote a quick example to show how this might work (with memoization built-in in order to avoid recompiling the same template multiple times).
What are your thoughts?
Beta Was this translation helpful? Give feedback.
All reactions