[Pharo-users] Slots doc

Vitor Medina Cruz vitormcruz at gmail.com
Wed Feb 6 12:17:40 EST 2019


Ok, thanks, I think I am understanding.

I was trying to create a class to experiment but if I try to:

Object subclass: #TestClassWithSlots
    slots: { }
    classVariables: {  }
    package: 'Experiment-Slots'

Code is reversed to:

Object subclass: #TestClassWithSlots
    instanceVariableNames: ''
    classVariableNames: ''
    package: 'Experiment-Slots'

Even if I do:

Object subclass: #TestClassWithSlots
    slots: { #tests => BaseSlot }
    classVariables: {  }
    package: ''Experiment-Slots'

It reverts back to the instanceVariableNames version. Putting BooleanSlot
avoids this reversion. I also tried to put RelationSlot just to see what
happens and it entered in an infinite loop error.

All those things are errors? If so, where should I report?



On Wed, Feb 6, 2019 at 10:46 AM Marcus Denker <marcus.denker at inria.fr>
wrote:

>
>
> On 6 Feb 2019, at 13:25, Vitor Medina Cruz <vitormcruz at gmail.com> wrote:
>
> Thanks, I was looking for usages of InstanceVariableSlot.
>
>
> All instance variables are InstanceVariableSlots.
>
> But to make it less verbose, we have a way to specify these without having
> to put the name.
>
>
> Object subclass: #Point
> slots: { #x. #y }
> classVariables: {  }
> package: 'Kernel-BasicObjects’
>
> is the same as
>
> Object subclass: #Point
> slots: { #x => InstanceVariableSlot . #y => InstanceVariableSlot}
> classVariables: {  }
> package: 'Kernel-BasicObjects'
>
> If you evaluate:
>
> Point slotNamed: #x
>
> you see that it returns a
>
>     #x => InstanceVariableSlot
>
> Slot instance.
>
> (with all that: I sometime wonder if we should not get rid of the name
> “Slot” and just use the term “Variable”… because that is what they are…)
>
>
>
> In the case of SlotExampleMovie, #name and #year are of
> IntanceVariableSlot layout (this definition is correct? A slot is or has
> some Layout defined by the Slot class?)
>
>
> No, the class has a Layout. See subclasses of AbstractLayout. This reifies
> the magic number that is in the “format” ivar of Behaviors (third ivar of
> all class like objects).
>
> In addition it makes class definition *explicitly* specify the layout.
>
> So Array in ST 80 is something like:
>
> ArrayedCollection variableSubclass: #Array
> instanceVariableNames: ''
> classVariableNames: ''
> package: 'Collections-Sequenceable-Base'
>
> so the layout chosen is hidden in the class creation method
> (variableSubclass…), while with the reified layouts, it explicit:
>
> ArrayedCollection subclass: #Array
> layout: VariableLayout
> slots: {  }
> classVariables: {  }
> package: 'Collections-Sequenceable-Base’
>
> e.g. for CompiledMethod it makes clear that is a very special class:
>
> CompiledCode subclass: #CompiledMethod
> layout: CompiledMethodLayout
> slots: {  }
> classVariables: {  }
> package: 'Kernel-Methods’
>
>
>
>
> On Wed, Feb 6, 2019 at 10:14 AM Marcus Denker <marcus.denker at inria.fr>
> wrote:
>
>>
>>
>> > On 6 Feb 2019, at 12:41, Denis Kudriashov <dionisiydk at gmail.com> wrote:
>> >
>> > Would be nice to have a command in browser to show users of selected
>> slot
>> >
>>
>> Yes!
>>
>>         Marcus
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20190206/1798b6c1/attachment.html>


More information about the Pharo-users mailing list