Returning closures to the user
breuleux opened this issue · 2 comments
breuleux commented
If the user defines a function that returns a closure, running it through the VM should return a callable object. In other words, the following should work, and it should print 30:
def f(x):
def g():
return x
return g
g = run(parse(f), [30])
print(g())
The same goes if the user somehow returns a primitive: it should return a callable version of the primitive.
At the moment, the VM returns an internal Closure type or the raw Primitive.
abergeron commented
We would need to do some post-processing on the returned value. It shouldn't be too hard.
breuleux commented
I'm going to work on that now, because I need it to test the output of the Grad transform.