On 12 Sep 2017, at 11:32, Denis Kudriashov <dionisiydk@gmail.com> wrote:

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?

It would be nice to improve it.. I like the idea of a ClassBinding subclass (this way it is distinct from Global Vars, too). The only question of adding one ivar to ca. 5000 Objects 
is not too much.. do we get enough out of it for that amount of memory?
Maybe there is some other possibility?

Marcus