alan icon indicating copy to clipboard operation
alan copied to clipboard

Closure functions

Open dfellis opened this issue 8 months ago • 0 comments

Implementing closures in Javascript will be super easy, but dealing with closure variables in Rust is much more difficult. Since Alan is being implemented as a pass-by-reference language and doesn't have recursion, ownership and lifetimes is super easy at-the-moment, but with closures, we need to know whether or not the closure will outlive the parent scope, and if it does, is it safe to move the outer variable or do we need to clone it first.

This will complicate the to-rs stage of the compiler, but it might be fine at the Microstatements layer. It will probably require a new statement type like the Arg type to handle enclosed variables.

dfellis avatar Jun 11 '24 00:06 dfellis