bindingOf question?

stéphane ducasse ducasse at iam.unibe.ch
Fri Nov 19 16:05:18 UTC 2004


Hi all

I'm wondering why the definition of bindingOf: is the following one:

Behavior>>bindingOf: varName
	"Answer the binding of some variable resolved in the scope of the 
receiver"
	^superclass bindingOf: varName

and not something more like that.

       	binding := self environment bindingOf: aSymbol.
	binding ifNotNil:[^binding].

	"Finally look higher up the superclass chain and fail at the end."
	superclass == nil
		ifTrue: [^ nil]
		ifFalse: [^ superclass bindingOf: aSymbol].

It seems to me that the current Behavior>>bindingOf is bogus.

Class>>bindingOf: varName
	"Answer the binding of some variable resolved in the scope of the 
receiver"
	| aSymbol binding |
	aSymbol := varName asSymbol.

	"First look in classVar dictionary."
	binding := self classPool bindingOf: aSymbol.
	binding ifNotNil:[^binding].

	"Next look in shared pools."
	self sharedPools do:[:pool |
		binding := pool bindingOf: aSymbol.
		binding ifNotNil:[^binding].
	].

	"Next look in declared environment."
	binding := self environment bindingOf: aSymbol.
	binding ifNotNil:[^binding].

	"Finally look higher up the superclass chain and fail at the end."
	superclass == nil
		ifTrue: [^ nil]
		ifFalse: [^ superclass bindingOf: aSymbol].




More information about the Squeak-dev mailing list