Discussion:
[Newbies] finding assignments to variables?
Ralph Boland
2018-07-23 23:14:31 UTC
Permalink
In squeak you can find out all references to a variable of a class
by clicking on the vars button.

Is there a way to find only the references to a variable of a class
that assigns a value to that variable?

Ralph Boland
Ron Teitelbaum
2018-07-24 02:20:53 UTC
Permalink
Hi Ralph,

You should be able to trace that using references. If you used a mutator
just do senders of the mutator.

so ivar foo

might have an accessor

MyClass >> foo
"return the value of foo"
^foo

and a mutator

MyClass >> foo: aFoo
"set the value of foo to aFoo"
foo := aFoo

if you only used the mutator to set the value of foo then senders of foo:
will give you what you are looking for.

if no use references. By the way, if you did things this way references
will show your accessor and mutator, which is why I said you should be able
to trace it (by doing senders of what is returned by references.

All the best,

Ron Teitelbaum
Post by Ralph Boland
In squeak you can find out all references to a variable of a class
by clicking on the vars button.
Is there a way to find only the references to a variable of a class
that assigns a value to that variable?
Ralph Boland
_______________________________________________
Beginners mailing list
http://lists.squeakfoundation.org/mailman/listinfo/beginners
K K Subbu
2018-07-24 05:22:55 UTC
Permalink
Post by Ralph Boland
In squeak you can find out all references to a variable of a class
by clicking on the vars button.
Is there a way to find only the references to a variable of a class
that assigns a value to that variable?
Instance variables are also objects, as are classes. When inspecting an
object, you can right click on self or any instance variable and select
"methods storing into this inst var".

HTH .. Subbu
Ralph Boland
2018-07-24 18:54:33 UTC
Permalink
Post by K K Subbu
Post by Ralph Boland
In squeak you can find out all references to a variable of a class
by clicking on the vars button.
Is there a way to find only the references to a variable of a class
that assigns a value to that variable?
Instance variables are also objects, as are classes. When inspecting an
object, you can right click on self or any instance variable and select
"methods storing into this inst var".
HTH .. Subbu
Thanks Subbu (and others for their comments).

Based on this advice I went exploring the debugger to figure out what code
was executed when this menu selection was made.
I eventually figured out that when the method <browseVariableAssignments>
(implemented by several classes) is invoked a list of variables is presented
to the user to choose from and for the selected variable a list of methods
assigning to that variable is presented. i.e. what I wanted.

Among the senders of this method are the debugger, inspector, and browsers.
To send this method bring up the (correct) menu in, for example a browser, and
select: 'assignments... (a)'.

Going forward this knowledge will be a great help.

Might be nice if right clicking on the 'Vars' button also did this but I have
99.9 percent of what I wanted to I'm happy.

Ralph

Loading...