Closed s-leroux closed 7 months ago
The new interpreter introduced in 3161ebf3aff4cf23d8d29e0b31172c116205ddee is right-associative.
So (callable_1, callable_2, "X")
is interpreted as (callable_1, (callable_2, "X"))
.
If callable_2
has to be interpreted as a nullary function, it requires explicit wrapping in a 1-tuple: (callable_1, (callable_2,), "X")
. The error-prone part here is the trailing comma required by Python for 1-tuple.
One solution would be allowing for wrapping expressions in other sequences, like lists:
(callable_1, [callable_2], "X")
I don't particularly like that solution. See #12 for another possible interpretation of the list literals.
Another option would be to introduce a higher-order function to rewrite the expression:
def singleton(fct):
def _singleton(*args):
return ((fct,),args)
return _singleton
(callable_1, singleton(callable_2), "X")
Closing as stale.
https://github.com/s-leroux/fin/blob/1d7dbf85eceb1bebb41be36195dc99180bff6fc7/examples/fin/model/warrant_price_change.py#L40
In some circumstances, the column mini-language requires wrapping the argument in a 1-tuple. This is confusing.
In practice, the following code is ambiguous:
Using the infix notation, it can be parsed either as
callable(callable(), "X")
orcallable(callable("X"))
or evencallable(callable()), "X"
.