<HTML>
<HEAD>
<TITLE>Re: [Q] Why Squeak don't have a Singleton class ?</TITLE>
</HEAD>
<BODY>
<FONT SIZE="2"><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>stijn timbermont puso en su mail :<BR>
<BR>
</SPAN></FONT></FONT><BLOCKQUOTE><FONT SIZE="2"><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>No, you shouldn't :-)<BR>
But this is a well-known problem in meta-programming<BR>
<BR>
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)<BR>
<BR>
A better example is the concept of an abstract class, with concrete subclasses:<BR>
A is an abstract class, so 'A class&gt;&gt;new' raises an error (like with a singleton) <BR>
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.<BR>
So it is not always conceptually right for classes and their metaclasses to inherit in parallel.<BR>
<BR>
This paper explains the problem clearly and proposes a solution which uses code (and class) generation <BR>
Safe Metaclass Programming (1998) ( Noury M.N. Bouraqadi-Sa&acirc;dani, Thomas Ledoux, Fred Rivard)<BR>
<FONT COLOR="#0000FF"><U><a href="http://citeseer.ist.psu.edu/37617.html">http://citeseer.ist.psu.edu/37617.html</a><BR>
</U></FONT><BR>
This paper uses traits for metaclass programming <BR>
Uniform and safe metaclass composition (St&eacute;phane Ducasse, Nathanael Sch&auml;rli, Roel Wuyts)<BR>
<FONT COLOR="#0000FF"><U><a href="http://www.iam.unibe.ch/~scg/Archive/Papers/Duca05ySafeMetaclassTrait.pdf">http://www.iam.unibe.ch/~scg/Archive/Papers/Duca05ySafeMetaclassTrait.pdf</a></U></FONT> &nbsp;&lt;<FONT COLOR="#0000FF"><U><a href="http://www.iam.unibe.ch/~scg/Archive/Papers/Duca05ySafeMetaclassTrait.pdf">http://www.iam.unibe.ch/~scg/Archive/Papers/Duca05ySafeMetaclassTrait.pdf</a></U></FONT>&gt; <BR>
</SPAN></FONT></FONT></BLOCKQUOTE><FONT SIZE="2"><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
stijn<BR>
Very thanks !!.<BR>
Useful reading.</SPAN></FONT></FONT>
</BODY>
</HTML>