[Newbies] Objects graph
Mateusz Grotek
unoduetre at poczta.onet.pl
Thu Sep 27 16:48:04 UTC 2012
Dear Squeakers,
I have the following problem:
Please imagine objects as a directed graph.
What I want to do is to run a method exactly once for each object. I can
do it in O(N*log(N)) time by using a tree or other datastructures. It
seems it's impossible to do it in O(N). The reason for that is there is
a comment in Object class which says I should not extend it by adding
any additional instance variables.
Additional points:
1. I want to be able to do this for ANY object, so subclassing and
adding an instance variable to a subclass won't work. (imagine for
example, that I need to create an extension of Smalltalk which should
work with all current Smalltalk classes, or something like that)
2. I cannot create an isomorphic graph with some other objects (of a
special class created by me), because I do not know how to detect
sharing of subobjects and cycles.
Is there a nice solution of this problem? What would happen if I add an
instance variable to Object (besides more memory used)? Do you think
adding one instance variable to Object class as a standard feature of
Squeak's library would break anything. This variable could be used for
example in veryDeepCopy etc. Maybe it's not a good idea...
Kind regards,
Mateusz
More information about the Beginners
mailing list