I found interesting trick in system: the way how class side perform
#binding message:

Metaclass>>binding
"return an association that can be used as the binding
To share it between methods, reuse an existing one if possible"
^self methodDict
ifEmpty: [nil -> self]
ifNotEmpty: [:dict | dict anyOne classBinding]

It leads to interesting behaviour of class without class side methods:

NewClass class binding == NewClass class binding "==> false"


Generally I discovered in the logic which decode class of method in last
literal. Interesting that for instance side methods it is always
represented by GlobalVariable. And for class side methods it is always
general Association.

Can we make this behaviour more consistent? And will it improve the system?
(I thing about possible complications to bootstrap).

As solution I would introduce new kind of LiteralVariable: ClassBinding
with two subclasses InstanceSideBinding and ClassSideBinding. They will
take place in last method literal.
InstanceSideBinding will be used in Smalltalk dictionary for classes
instead of GlobalVariable.
And it will keep variable with class side binding. So the trick will be not
needed anymore.

So what do you think?

Reply via email to