|
From: rna020 <tom...@fr...> - 2008-01-18 16:41:16
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> Neil Madden wrote: <blockquote cite="mid:913...@cs..." type="cite"> <meta http-equiv="Content-Type" content="text/html; "> <meta name="Generator" content="MS Exchange Server version 6.5.7652.24"> <title>Re: [TCLCORE] Empty list is not a list -- using twoPtrValue forNULL type</title> <!-- Converted from text/plain format --> <br> <p><font size="2">On 17 Jan 2008, at 23:53, Alexandre Ferrieux wrote:<br> ><br> > OK, sorry for the delay :-) Here it goes.<br> > Sorry in advance for the obvious introduction, but let's start from<br> > the basics to be sure.<br> ><br> > Mutability - principle<br> > -----------------------------<br> ><br> > Values in Tcl, be they "scalars" like integers or strings, or<br> > "containers" like lists or dicts, are so far strictly independent from<br> > one another. Hence, in<br> ><br> > # assuming no trick like upvar #0 x y<br> > set x [function call returning some value]<br> > set y $x<br> > do anything to y<br> ><br> > the $x value will *never* be touched by whatever is done to the<br> > variable y, including "in-place" operations like [lappend], [lset],<br> > etc. In other words, as seen from the script level, values can just be<br> > copied, never passed "by reference".<br> <br> Nit picking, but values, strictly speaking, are always immutable. <br> It's variables that are passed by reference in most languages, or <br> some kind of first-class reference cell or "object". This is an <br> important point, because presumably it doesn't make sense to make the <br> Tcl_Obj representation of "2" mutable. I mean, if "2" gets changed to <br> "3", what has happened? What *is* the explanation of:<br> </font></p> </blockquote> One of my first really nasty programming experiences was when I passed the <br> value "1" into a FORTRAN call that treated it as a variable. When the variable<br> got set to "0" all the "if" statements started behaving very strangely. FORTRAN<br> (at least) allows values to be mutable.<br> <br> Tom K.<br> <font size="2"><br> ... snip ...<br> </font> </body> </html> |