Path: utzoo!mnetor!uunet!tektronix!tekcrl!jans From: jans@tekcrl.TEK.COM (Jan Steinman) Newsgroups: comp.lang.smalltalk Subject: Re: Question concerning behavior of assignment and copy methods Message-ID: <2480@tekcrl.TEK.COM> Date: 31 Mar 88 20:36:45 GMT Organization: Tektronix Inc., Beaverton, Or. Lines: 33 Literal arrays are not constants in Smalltalk, and assignment is by reference. Therefore: b _ a _ 'Crazy Jane'. a at: 8 put: $u. Transcript show: b. will print 'Crazy June'. If this is done in a workspace, the visible text does not change -- the literal that changes is int the DoIt compiled method. If this code is placed in a method, a and b will indeed get initialized to 'Crazy June' the second time the method is executed. Note that the source code of such a method, like the visible text in the workspace example, does not change, which can cause considerable confusion! The preceeding Smalltalk code is roughly the similar to the following C code: static char a[] = "Crazy Jane"; char *b; b = a; a[7] = 'u'; printf("%s", b); :::::: Software Productivity Technologies --- Smalltalk Project :::::: :::::: Jan Steinman N7JDB Box 500, MS 50-470 (w)503/627-5881 :::::: :::::: jans@tekcrl.TEK.COM Beaverton, OR 97077 (h)503/657-7703 ::::::