Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (30 sloc) 1.09 kb
Need to be able to pass around closure values.
Also need to reconcile the various ways of storing a function.
Lower-level format.
Used primarily in reflection.
Function / Closure
Stores a Branch pointer
Stores the 'Environment' (a list of closed values)
Existing 'Function' type
Should be removed
Fields should be added to a NativeFunc field on the Branch
Code should pass around Branch* when talking about functions
The {} syntax must create a closure:
def main() -> Function
a = 1
return { print(a) }
Referring to a function by name must also create a closure:
def main() -> Function
a = 1
def print_a()
return print_a
1) Add a Func type, which may include a list of closed variables.
2) Whenever we compile a function, every external reference must be wrapped in a
external() term.
3) When calling a Func, each external() term must be filled in, either from the stack
or from the Func's environment.
4) When returning a Func value, we may need to capture values from the stack.
Jump to Line
Something went wrong with that request. Please try again.