[squeak-dev] Why are values in Undeclared unconditionally niled time and again?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Why are values in Undeclared unconditionally niled time and again?

Klaus D. Witzel
Hi,

when building a script there suddenly ways this situation:

- some methods where compiled, they had Undeclared variables (shown in  
Transcript)

- an expression in the script initilized these variables with values ~= nil

- some more methods where compiled, referencing the still undeclared  
variables

Bang! the values from the initialization step where nil again :(

- (here the script was aborted because it would never work).

Why are the variables nil'ed again by the compiler, or is it a bug? One  
would expect that the compiler touches the values in Undeclared only if  
their variables do not already exist. Instead, it nils them time and again.

Example expressions for reproducing the situation (formulated for  
non-interactive use, no popups), checked they do the same in 3.10.2, 3.9  
and 3.8 stock images:

  (Compiler evaluate: 'YourNameGoesHere := Object new' logged: true)

  (nil class compile: 'methName ^YourNameGoesHere' classified:  
#'*YourPackageNameGoesHere')

I would appreciate feedback on whether this is a bug or a feature (happens  
in method Encoder>>#undeclared:). It there something that depends on this?  
TIA.

/Klaus