Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pharo Smalltalk - How is variable scope in an Object achieved?

I'm experimenting in Pharo and I was wondering how class, instance variable scope is achieved.

More to the point, instance variables can be accessed by all the methods of that instance of a class, also class instance variables can be accessed by all the methods of the class and so on.

Where does the depth of this scope get defined in code? Can one see where and how this takes place, Smalltalk being fully Object Oriented?

like image 337
unom Avatar asked Oct 30 '22 19:10

unom


1 Answers

I presume you are in Pharo >= 4.0, in which case you have the so called OpalCompiler.

In OpalCompiler, the variable scope is reified (see OCAbstractScope and subclasses), the scope being used during semantic analysis of the Abstract Syntax Tree (see OCASTSemanticAnalyzer).

You now have an entry point, and should follow message senders, class refs, instance variable refs, ... from this starting point.

like image 164
aka.nice Avatar answered Nov 18 '22 03:11

aka.nice