json-formula
json-formula copied to clipboard
Calling registered functions with 0 arguments.
Currently in the spec:
The registered function may take one parameter.
It is pretty clear, that it would be implemented by just evaluating the expression with the argument as the contextual input JSON. But it is not quite clear, what that input should be in the json-formula context, when 0 arguments are provided.
In the current implementation, it looks like it just has js "undefined" as the input, which can leak in the results. For example, an expression like register("_identity", &@) || _identity() results in undefined.
Maybe it would be better to specify the default value for the argument in such cases, like null or {}?
Good question. I think null makes most sense.