Version 2 of copy-on-write

Updated 2006-09-13 18:13:53

[explain importance of this notion of immutability to proper understanding of Tcl's semantics]

Those who have a little knowledge of C (or other similar languages) have learned to pass arguments to a function by value or by reference.

Tcl scripts have such functionalities : when you need to pass the variable by value, you put a $ before the variable name. And this does not modifiy the variable.

But when you need to access uplevel variables, you can use upvar in the proc you call, passing just the name of the variable as argument. Then you can access the content of a variable defined in the upper stack level. This feature works especially good with arrays that cannot be passed by value.

But when you come to Tcl C API (the internals that are required to write C extensions), you must know how Tcl passes variables by value, which makes use of the copy-on-write semantics.


[and consequences for extension design]

   ???