msteveb / jimtcl

Official repository of Jim Tcl, an open-source, small footprint implementation of Tcl
http://jim.tcl.tk/
Other
432 stars 123 forks source link

core: add support for proc static variables by reference #265

Closed msteveb closed 1 year ago

msteveb commented 1 year ago

This is an experimental feature that allows for lexical closures in Jim Tcl by allowing procs (and lambdas) to capture variables by reference rather than by value. e.g.

set a 5

proc b {} {&a} {
    incr a
}

b

Now a is 6 because b captured a by reference instead of by value