1.3 KiB
1.3 KiB
Function Values, Captures, and Events
Summary of current behavior and guidelines.
- Function values: created via
function(...) { ... }produce aFunctionBoxwith captured environment (by-ref for locals viaRefCellBox, by-value for globals/statics) and optional weakme. - Assignment cell reflection: assigning to a variable or field bound to
RefCellBoxupdates the inner value instead of replacing the cell. this → me: inside methods,thisis bound asmefor field/method access. External code should preferme.- Parent:: syntax: parser groundwork exists for
Parent::methodreferences; calling from child uses from-call lowering. ?(propagate):expr ?lowers toisOk/getValuebranching and returns early with the Result on error.peek: tokenized and parsed; desugars to if-else chain in VM.
Event APIs
- P2PBox.on/onOnce/off: handlers now accept both
MethodBoxandFunctionBox.MethodBoxhandlers invoke the bound method on receive with arguments(intent, from).FunctionBoxhandlers execute the function body with params bound from(intent, from)(excess args ignored).
Notes
- RefCell-backed locals captured by closures will reflect assignments (
x = ...) in the outer scope. - For plugin-backed boxes, assignment and argument passing uses share semantics to preserve identity.