[Q] Why Squeak don't have a Singleton class ?

Lic. Edgar J. De Cleene edgardec2001 at yahoo.com.ar
Sat Dec 3 12:30:19 UTC 2005


stijn timbermont puso en su mail :

> No, you shouldn't :-)
> But this is a well-known problem in meta-programming
> 
> The reason why you cannot do this in smalltalk is because, when you have a
> class A and a subclass B, the metaclass of B (being 'B class') must be a
> subclass of the metaclass of A (being 'A class'). (The reason for this is to
> guarantee upward and downward compatibility - see links below. In CLOS, one is
> allowed to choose any metaclass in the class definition, but no compatibility
> is guaranteed)
> 
> A better example is the concept of an abstract class, with concrete
> subclasses:
> A is an abstract class, so 'A class>>new' raises an error (like with a
> singleton) 
> B is a subclass of A, inheriting all behaviour from A, and 'B class' (a
> concrete class) is a subclass of 'A class': a concrete class inheriting its
> behaviour from an abstract class.
> So it is not always conceptually right for classes and their metaclasses to
> inherit in parallel.
> 
> This paper explains the problem clearly and proposes a solution which uses
> code (and class) generation
> Safe Metaclass Programming (1998) ( Noury M.N. Bouraqadi-Saâdani, Thomas
> Ledoux, Fred Rivard)
> http://citeseer.ist.psu.edu/37617.html
> 
> This paper uses traits for metaclass programming
> Uniform and safe metaclass composition (Stéphane Ducasse, Nathanael Schärli,
> Roel Wuyts)
> http://www.iam.unibe.ch/~scg/Archive/Papers/Duca05ySafeMetaclassTrait.pdf
> <http://www.iam.unibe.ch/~scg/Archive/Papers/Duca05ySafeMetaclassTrait.pdf>

stijn
Very thanks !!.
Useful reading.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20051203/9b80184b/attachment.htm


More information about the Squeak-dev mailing list