If you defined the variable as an instance variable in the class side, you
can access it as

Greeter instVarNamed: 'greeting'
or
Greeter instVarAt: 1


But also you can define class variables from the instance side, which is
slightly different (and I think most common, isn't it?)

Object subclass: #Greeter
instanceVariableNames: ''
classVariableNames: 'greeting'
package: 'Greetings'

if that is the case, there is in fact a dictionary which is accessed by
doing

Greeting classPool


On Mon, Oct 3, 2016 at 10:23 PM, CodeDmitry <[email protected]> wrote:

> I am trying to study Pharo's internals and I am now curious how it stores
> class variables.
>
> I notice that in order to have a class `Greeter` with a "static" variable
> `greeting`, I need to make `greeting` an instance variable under "show show
> the class side" and create a "Getter" and "Setter" for this "instance
> variable".
>
> First thing that confuses me is, why is this called an instance variable if
> this particular "static" method is not bound to any particular instance? Is
> it just because it is defined in an "instance" of a "ProtoClass"?
>
> Second thing that confuses me is, where are these pairs of ("instance
> variable name" => "instance variable value") stored? I know that I can call
>
> Transcript show:
>     ((Greeter class) instanceVariables at: 1).
>
> which prints "greeting".
>
> and
>
> Transcript show:
>   Greeter instanceVariables class.
>
> which prints "Array"(curious, i expected a Dictionary mapping Strings to
> Object).
>
> Transcript show:
>     ((Greeter class) instanceVariables at: 1) class.
>
> prints "ByteSymbol".
>
> Now I am confused, where are the actual values of the "static variables"
> stored? I can find the names, but  can't understand where  the values are
> hidden.
>
> Can somebody help me understand  this?
>
>
>
>
> --
> View this message in context: http://forum.world.st/How-
> does-Pharo-store-instance-variables-tp4917924.html
> Sent from the Pharo Smalltalk Developers mailing list archive at
> Nabble.com.
>
>

Reply via email to