[squeak-dev] Re: On class/metaclass coupling
siguctua at gmail.com
Tue Dec 8 17:20:00 UTC 2009
2009/12/8 Andreas Raab <andreas.raab at gmx.de>:
> Igor Stasenko wrote:
>> For people who think that we should not revise the class/metaclass
>> coupling in Squeak,
>> just ignore this topic and consider it as a rant :)
>> For those, who interested why i think its not a perfect from
>> object-oriented point of view, continue reading.
> It may help your thinking about the problem when you realize that the core
> coupling between object and class, is as simple as:
> Class new class == Class.
erm.. at least 2 messages between 'Class' to the left and 'Class' to
the right could do something completely different,
so as result you will get false (or something else, if #== overridden
itself). Of course i leaving an aggressive optimization of #class and
As any expression you writing in smalltalk, you can't tell what will
be result before evaluating it.
> I.e., if you can implement the #class method you could do something like:
> ^FooClass new
> This will work perfectly fine in terms of the "everyday use" of classes. I
> had thought about utilizing this to create "safe classes" that is classes
> that separate the factory / utility aspect from the vtable aspect
> (FooFactory can expose instance creation and utility methods without
> exposing the implemntation / compilation aspect provided by FooClass
There are few aspects, which is hardcoded in VM in respect, what
objects could serve as an object factory
(by using #basicNew, or #basicNew: primitives).
One could easily create own factory objects, as soon as VM
requirements met ('superclass methodDict format' slots).
"If it walks like a duck and quacks like a duck, it must be a duck"
Btw, by reading an essay (a link provided by Eliot few days ago) where
discussed a difference between ADT (abstract data types) and objects,
there were very good observation about objects, which is a good
complement to duck typing:
Two objects considered equal, if they simulating each one's behavior.
> - Andreas
Igor Stasenko AKA sig.
More information about the Squeak-dev