Open rtulip opened 1 year ago
Right now, there's no way to pass functions as parameters on the stack.
We should be able to use the existing unary & expression to push a function pointer on the stack:
&
fn foo() -> [u64] 12345 fn main() { &foo // pushes fn() -> [u64] onto stack. }
Calling can be done by "de-referencing" the function pointer:
fn main() { &foo @ println }
As a type, it can be represented by something like:
fn for_each(&Vec<T>: v fn(T) -> []: func) { 0 while dup v Vec.get dup Option.take_is_some do { Option.unwrap func @ 1 + } drop drop }
Right now, there's no way to pass functions as parameters on the stack.
Semantics:
We should be able to use the existing unary
&
expression to push a function pointer on the stack:Calling can be done by "de-referencing" the function pointer:
As a type, it can be represented by something like: