[Pharo-users] Slots doc

Marcus Denker marcus.denker at inria.fr
Wed Feb 6 07:44:59 EST 2019



> 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 <mailto:marcus.denker at inria.fr>> wrote:
> 
> 
> > On 6 Feb 2019, at 12:41, Denis Kudriashov <dionisiydk at gmail.com <mailto: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/ea265416/attachment.html>


More information about the Pharo-users mailing list