[squeak-dev] private instance variables NOT objects? (Wikipedia)

Jecel Assumpcao Jr. jecel at merlintec.com
Mon Oct 25 22:18:21 UTC 2010


I agree with Eliot that we should very clearly answer the question "are
instance variables objects?" with "no: but they hold references to
objects".

But I would like to discuss some related questions -

"Could instance variables be objects?"

Yes, but there would be significant costs. You would have to solve issus
of infinite regress (how do you represent the instances variables of the
instance variables? And the instance variables of the instance variables
of the instance variables? And so on....) and even then they would add
significant overhead to the implementation.

"Would anything good come from having instance variables be objects?"

Debuggers, browsers and other tools could be written in more object
oriented and less imperative style. In fact, the compiler does create
objects for the instance variables while doing its job but throws these
objects away when it is finished.

"Is there some way to have the advantages of variables as objects
without all the costs?"

The compiler shows it can be done - only have them be objects when you
happen to be looking at them but not otherwise. Self mirrors are a great
example of this - when you create a mirror on some object, it seems to
be a set of "slot" objects. You can send many interesting messages to
the individual slots as well as to the whole set. For any object on
which you don't have a mirror, no slot objects exist.

-- Jecel




More information about the Squeak-dev mailing list