[FIX] Re: [BUG][Modules] Beware! Pool constants visible globally

Henrik Gedenryd h.gedenryd at open.ac.uk
Sat Feb 2 21:35:39 UTC 2002


Andreas Raab wrote:

> BEWARE! WonderlandConstants has various constants that are _lower_ case.
> In other words, if you write a method like
> 
> Object>>foo: bar
> above := bar.
> ^above
> 
> the system will _not_ warn you that above is undeclared but rather
> assign to the binding from WonderlandConstants. Ouch!
> 
> Anyone having an idea _why_ these are visible? Or even better, how to
> fix this problem? I can't imagine that we introduced a module system
> just to add _more_ globals... ;-)

Ok, the attached small change should solve this. Pool variables aren't
visible any more.

Try it and notify me about any problems.

Henrik

-------------- next part --------------
'From Squeak3.3alpha of 30 January 2002 [latest update: #4735] on 2 February 2002 at 9:32:05 pm'!
"Change Set:		nameLookupFixes-hg
Date:			2 February 2002
Author:			Henrik Gedenryd"

(Preferences preferenceAt:  #lenientScopeForGlobals) name: #lenientScopeForGlobals defaultValue: true helpString: 'Should global name lookup check in Smalltalk if not found during ''proper'' module name lookup? (Should be on until module dependencies are fully declared in the image.)' localToProject: false categoryList: #(modules) changeInformee: nil changeSelector:  nil.

(Module @ #(Squeak VMConstruction Plugins Balloon) externalModule: #(Squeak Media Balloon Drawing BalloonEngineConstants) alias: nil version: nil importNames: false) resolveModule 

(Module @ #(Squeak VMConstruction Plugins Balloon3D)  externalModule:  #(Squeak Media Balloon3D Engine B3DEngineConstants) alias: nil version: nil importNames: false) resolveModule

(Module @ #(Squeak VMConstruction Plugins Sound) externalModule: #(Squeak Media Speech Klatt KlattResonatorIndices) alias: nil version: nil importNames: false) resolveModule 

(Module @ #(Squeak EToy UserObjects) externalModule: #(Squeak EToy Scripting References) alias: nil version: nil importNames: false) resolveModule !


!Module methodsFor: 'name lookup schemes' stamp: 'hg 2/2/2002 21:04'!
lenientDefinesName: varName ifTrue: assocBlock
	"extra check to allows unrestricted use of global names."

	"Look it up in Smalltalk to allow references to all global names (except modules)."
	self class smalltalk associationFor: varName ifPresent: [:a :mod |
		assocBlock value: a.
		^ true]. 

	"another lookup just to catch what were formerly Pool variables"
	"^self class root definesName: varName ifTrue: [:a |
		assocBlock value: a]"
	
	^false! !



More information about the Squeak-dev mailing list