Slots

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

Slots

Bob Williams
I am trying to duplicate the typed slot example in the paper "Flexible Object Layout". I did create the classes for TypedSlot and FloatSlot, but I am trying to find the best way to set the type for class FloatSlot to the class Float. In the example in the paper it appears to be set at the time the class is created however that does not seem to be an option when using PharoClassInstaller. I was thinking about using some form of lazy initialization, but is there a better way; a method anticipated by the Pharo 3 designers? I used:

PharoClassInstaller make: [ :aSCB |
    aSCB
        superclass: Slot;
        name: #TypedSlot;
        slots: #(type);
        category: 'BW-Testing' ].
   
PharoClassInstaller make: [ :aSCB |
    aSCB
        superclass: TypedSlot;
        name: #FloatSlot;
        category: 'BW-Testing' ].

bw
Reply | Threaded
Open this post in threaded view
|

Re: Slots

camille teruel
You can use the old syntax for class declaration for creating classes, i.e. :

Superclass subclass: #MyClass
instanceVariableNames: 'x y z' 
classVariableNames: '' 
category: 'MyProject'

However, the compiler does not take slots into account yet, so custom slots will only be available for Pharo 4.
There is a still some work to do in the new class builder and in the slot architecture to make it usable.

On 7 juin 2014, at 17:48, Bob Williams <[hidden email]> wrote:

I am trying to duplicate the typed slot example in the paper "Flexible Object Layout". I did create the classes for TypedSlot and FloatSlot, but I am trying to find the best way to set the type for class FloatSlot to the class Float. In the example in the paper it appears to be set at the time the class is created however that does not seem to be an option when using PharoClassInstaller. I was thinking about using some form of lazy initialization, but is there a better way; a method anticipated by the Pharo 3 designers? I used:

PharoClassInstaller make: [ :aSCB |
    aSCB
        superclass: Slot;
        name: #TypedSlot;
        slots: #(type);
        category: 'BW-Testing' ].
   
PharoClassInstaller make: [ :aSCB |
    aSCB
        superclass: TypedSlot;
        name: #FloatSlot;
        category: 'BW-Testing' ].

bw

Reply | Threaded
Open this post in threaded view
|

Re: Slots

Marcus Denker-4

On 07 Jun 2014, at 19:32, Camille Teruel <[hidden email]> wrote:

> You can use the old syntax for class declaration for creating classes, i.e. :
>
> Superclass subclass: #MyClass
> instanceVariableNames: 'x y z'
> classVariableNames: ''
> category: 'MyProject'
>
> However, the compiler does not take slots into account yet, so custom slots will only be available for Pharo 4.
> There is a still some work to do in the new class builder and in the slot architecture to make it usable.
>
Yes, we need to start to really work on that… right now the state is that there is only one kind of Slot which
is the classic Ivar Slot.

If we want more, we need to add some more infrastructure first
        -> Slot needs to be the abstract superlclass of all slots
        -> Ivar slot needs to be a subclass
        -> the compiler needs to delegate code generation to the slot class
        -> we need a new class template for classes with slots
        -> Monticello support


        Marcus