Metaclasses and co.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Metaclasses and co.

Alexandre Bergel-2
Today I spend some time to read and understand an old mail from  
Andreas (http://lists.squeakfoundation.org/pipermail/squeak-dev/2005- 
October/096370.html) about having a parallel metaclass hierarchy. I  
really like this.

Thanks Andreas!!

I wrote a short test to understand it, I think it might interest some  
of you:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
testClassCreation
        "self debug: #testClassCreation"
        | mcls cls |

        mcls := MyMetaclass
                subclass: #MC
                instanceVariableNames: ''
                classVariableNames: ''
                poolDictionaries: ''
                category: 'MyMetaClassesGenerated'.
        cls := MyObject
                subclass: #C
                instanceVariableNames: ''
                classVariableNames: ''
                poolDictionaries: ''
                category: 'MyMetaClassesGenerated'
                metaclass: mcls.
        classCreated addAll: {mcls . cls}. "Used in teardown to remove the  
classes"
       
        mcls compile: 'foo ^20'.
       
        self assert: (cls new class == cls).
        self assert: (cls class name = 'C class').
        self assert: (cls class class == mcls).
        self assert: (cls class class class class == MyMetaclass).
        self assert: (cls class soleInstance == cls).

        self assert: (cls canUnderstand: #foo) not.
        self assert: (cls class respondsTo: #foo).
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Cheers,
Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.cs.tcd.ie/Alexandre.Bergel
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.




Reply | Threaded
Open this post in threaded view
|

Re: Metaclasses and co.

Noury Bouraqadi
Hi,

Remember there is MetaclassTalk  
(http://csl.ensm-douai.fr/MetaclassTalk) that provides explicit  
metaclasses and other reflective facilities for Squeak. You can define  
your own metaclasses and use them in order to have classes with the  
following protocole :

Object subclass: #Person
        instanceVariableNames: 'name age '
        classVariableNames: ''
        poolDictionaries: ''
        category: 'MetaclassTalk-Examples'
        metaclass: MyMetaclass

One intersting application of explicit metaclasses I did is to  extend  
Smalltalk with mixin-based inheritance.
However, neither implicit metaclasses (with parallel hierarchies) nor  
explicit metaclasses are totally satisfactory. Actually, there should  
be a mix of both (see my papers on metaclass compatibility OOPSLA98,  
ESUG2003).

Noury
Le 16 févr. 06, à 19:37, Bergel, Alexandre a écrit :

> Today I spend some time to read and understand an old mail from  
> Andreas  
> (http://lists.squeakfoundation.org/pipermail/squeak-dev/2005-October/ 
> 096370.html) about having a parallel metaclass hierarchy. I really  
> like this.
>
> Thanks Andreas!!
>
> I wrote a short test to understand it, I think it might interest some  
> of you:
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> testClassCreation
> "self debug: #testClassCreation"
> | mcls cls |
>
> mcls := MyMetaclass
> subclass: #MC
> instanceVariableNames: ''
> classVariableNames: ''
> poolDictionaries: ''
> category: 'MyMetaClassesGenerated'.
> cls := MyObject
> subclass: #C
> instanceVariableNames: ''
> classVariableNames: ''
> poolDictionaries: ''
> category: 'MyMetaClassesGenerated'
> metaclass: mcls.
> classCreated addAll: {mcls . cls}. "Used in teardown to remove the  
> classes"
>
> mcls compile: 'foo ^20'.
>
> self assert: (cls new class == cls).
> self assert: (cls class name = 'C class').
> self assert: (cls class class == mcls).
> self assert: (cls class class class class == MyMetaclass).
> self assert: (cls class soleInstance == cls).
>
> self assert: (cls canUnderstand: #foo) not.
> self assert: (cls class respondsTo: #foo).
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> Cheers,
> Alexandre
> --
> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
> Alexandre Bergel  http://www.cs.tcd.ie/Alexandre.Bergel
> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>
>
>
>
--------------------------------------------------------------
Dr. Noury Bouraqadi - Enseignant/Chercheur
Ecole des Mines de Douai - Dept. G.I.P
http://csl.ensm-douai.fr/noury

European Smalltalk Users Group Board
http://www.esug.org

Squeak: an Open Source Smalltalk
http://www.squeak.org
--------------------------------------------------------------



Reply | Threaded
Open this post in threaded view
|

Re: Metaclasses and co.

Alexandre Bergel-2
According to the wiki page, Squeak 3.2 seems to be the platform used  
for Metaclasstalk...
Do you have the changeset somewhere ? Will it work with squeak 7000 ?
Traits showed it should be difficult to make a .mcz file for this  
kind of think...

Cheers,
Alexandre


Am Feb 20, 2006 um 9:16 PM schrieb Noury Bouraqadi:

> Hi,
>
> Remember there is MetaclassTalk (http://csl.ensm-douai.fr/ 
> MetaclassTalk) that provides explicit metaclasses and other  
> reflective facilities for Squeak. You can define your own  
> metaclasses and use them in order to have classes with the  
> following protocole :
>
> Object subclass: #Person
> instanceVariableNames: 'name age '
> classVariableNames: ''
> poolDictionaries: ''
> category: 'MetaclassTalk-Examples'
> metaclass: MyMetaclass
>
> One intersting application of explicit metaclasses I did is to  
> extend Smalltalk with mixin-based inheritance.
> However, neither implicit metaclasses (with parallel hierarchies)  
> nor explicit metaclasses are totally satisfactory. Actually, there  
> should be a mix of both (see my papers on metaclass compatibility  
> OOPSLA98, ESUG2003).
>
> Noury
> Le 16 févr. 06, à 19:37, Bergel, Alexandre a écrit :
>
>> Today I spend some time to read and understand an old mail from  
>> Andreas (http://lists.squeakfoundation.org/pipermail/squeak-dev/ 
>> 2005-October/096370.html) about having a parallel metaclass  
>> hierarchy. I really like this.
>>
>> Thanks Andreas!!
>>
>> I wrote a short test to understand it, I think it might interest  
>> some of you:
>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>> testClassCreation
>> "self debug: #testClassCreation"
>> | mcls cls |
>>
>> mcls := MyMetaclass
>> subclass: #MC
>> instanceVariableNames: ''
>> classVariableNames: ''
>> poolDictionaries: ''
>> category: 'MyMetaClassesGenerated'.
>> cls := MyObject
>> subclass: #C
>> instanceVariableNames: ''
>> classVariableNames: ''
>> poolDictionaries: ''
>> category: 'MyMetaClassesGenerated'
>> metaclass: mcls.
>> classCreated addAll: {mcls . cls}. "Used in teardown to remove  
>> the classes"
>>
>> mcls compile: 'foo ^20'.
>>
>> self assert: (cls new class == cls).
>> self assert: (cls class name = 'C class').
>> self assert: (cls class class == mcls).
>> self assert: (cls class class class class == MyMetaclass).
>> self assert: (cls class soleInstance == cls).
>>
>> self assert: (cls canUnderstand: #foo) not.
>> self assert: (cls class respondsTo: #foo).
>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>>
>> Cheers,
>> Alexandre
>> --
>> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
>> Alexandre Bergel  http://www.cs.tcd.ie/Alexandre.Bergel
>> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>>
>>
>>
>>
> --------------------------------------------------------------
> Dr. Noury Bouraqadi - Enseignant/Chercheur
> Ecole des Mines de Douai - Dept. G.I.P
> http://csl.ensm-douai.fr/noury
>
> European Smalltalk Users Group Board
> http://www.esug.org
>
> Squeak: an Open Source Smalltalk
> http://www.squeak.org
> --------------------------------------------------------------
>
>
>

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.cs.tcd.ie/Alexandre.Bergel
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.




Reply | Threaded
Open this post in threaded view
|

Re: Metaclasses and co.

stéphane ducasse-2

On 20 févr. 06, at 23:36, Alexandre Bergel wrote:

> According to the wiki page, Squeak 3.2 seems to be the platform  
> used for Metaclasstalk...
> Do you have the changeset somewhere ? Will it work with squeak 7000 ?
> Traits showed it should be difficult to make a .mcz file for this  
> kind of think...

Why? They should be orthogonal
can you elaborate?



Reply | Threaded
Open this post in threaded view
|

Re: Metaclasses and co.

Alexandre Bergel-2
> Why? They should be orthogonal
> can you elaborate?

I guess Metaclasstalk needs a kind of bootstrap mechanism. Which are  
difficult to package with a .mcz.
I played a bit with a new metaclass hierarchy, and I had problem to  
have a .mcz file. And what I did was simple...

I am not saying that metaclasstalk interferes with traits. I am just  
saying that as it is difficult to produce a .mcz for traits, it is  
(probably) difficult to produce a .mcz for metaclasstalk.

Alexandre

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.cs.tcd.ie/Alexandre.Bergel
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.




Reply | Threaded
Open this post in threaded view
|

Re: Metaclasses and co.

Noury Bouraqadi
Actually, I didn't port MetaclassTalk because I'm lacking time to do
it. However, if you're intersted in it, I can help you.

Regarding monticello and bootstrapping, I guess this  can be done in
some class initialize method.
However, conceptually speaking, I don't like that class initialize
method be used for package initializiation.
It looks to me more like a hack to workarround a weakness of MC.

Noury
Le 21 févr. 06, à 16:43, Alexandre Bergel a écrit :

>> Why? They should be orthogonal
>> can you elaborate?
>
> I guess Metaclasstalk needs a kind of bootstrap mechanism. Which are
> difficult to package with a .mcz.
> I played a bit with a new metaclass hierarchy, and I had problem to
> have a .mcz file. And what I did was simple...
>
> I am not saying that metaclasstalk interferes with traits. I am just
> saying that as it is difficult to produce a .mcz for traits, it is
> (probably) difficult to produce a .mcz for metaclasstalk.
>
> Alexandre
>
> --
> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
> Alexandre Bergel  http://www.cs.tcd.ie/Alexandre.Bergel
> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>
>
>
>
>
--------------------------------------------------------------
Dr. Noury Bouraqadi - Enseignant/Chercheur
Ecole des Mines de Douai - Dept. G.I.P
http://csl.ensm-douai.fr/noury

European Smalltalk Users Group Board
http://www.esug.org

Squeak: an Open Source Smalltalk
http://www.squeak.org
--------------------------------------------------------------