guppylang icon indicating copy to clipboard operation
guppylang copied to clipboard

Allow loading function pointers via comptime expressions

Open mark-koch opened this issue 7 months ago • 1 comments

@guppy
def foo() -> int: ...

@guppy
def bar() -> int: ...

@guppy
def main() -> int:
    f = comptime(foo if condition() else bar)
    return f()

mark-koch avatar Jun 03 '25 15:06 mark-koch

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

mark-koch avatar Jun 05 '25 16:06 mark-koch