Make all maje functions somewhat "lazy"? #48

Open
opened 2025-12-19 22:06:00 +00:00 by glen · 1 comment
Owner

Now that we are able to type a maje expression (i.e., deduce the type it will evaluate to without evaluating it), there is a possibility we could arrange that in maje, it's actually the subexpressions (i.e. parse trees) that are always provided as arguments to a function call. If, as in the ordinary case, the function has no implementations matching parse tree arguments, the parse trees would just be converted to their values of the computed type by an automatic conversion that evaluates the parse tree. On the other hand, for short-circuiting operations like 'and' or functions like 'derivative' that want to work on parse trees, there would be no need to mark them as "raw" functions -- they could simply define matches on the parse tree types, and then they would receive the parse trees as actual arguments in those implementations.

Now that we are able to type a maje expression (i.e., deduce the type it will evaluate to without evaluating it), there is a possibility we could arrange that in maje, it's actually the subexpressions (i.e. parse trees) that are _always_ provided as arguments to a function call. If, as in the ordinary case, the function has no implementations matching parse tree arguments, the parse trees would just be converted to their values of the computed type by an automatic conversion that evaluates the parse tree. On the other hand, for short-circuiting operations like 'and' or functions like 'derivative' that want to work on parse trees, there would be no need to mark them as "raw" functions -- they could simply define matches on the parse tree types, and then they would receive the parse trees as actual arguments in those implementations.
Author
Owner

(I guess that derivative is not currently marked as raw, in that derivative(x^2) throws an undefined symbol error in the mathjs.org REPL right now. So this feature, if we implemented it, could potentially streamline the use of derivative from where it stands now.)

(I guess that `derivative` is not currently marked as raw, in that `derivative(x^2)` throws an undefined symbol error in the mathjs.org REPL right now. So this feature, if we implemented it, could potentially streamline the use of `derivative` from where it stands now.)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
StudioInfinity/nanomath#48
No description provided.