guppylang
guppylang copied to clipboard
Allow loading function pointers via comptime expressions
@guppy
def foo() -> int: ...
@guppy
def bar() -> int: ...
@guppy
def main() -> int:
f = comptime(foo if condition() else bar)
return f()
The main obstacle here is that we can't put them in Const nodes since they could call functions from the outside.
But this is a problem for lists of functions: They would need to lower to hugr static_arrays, but they can only live in const nodes...
Either we don't allow lists containing functions, or we need to use regular arrays instead of static ones