finding assignments to variables?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

finding assignments to variables?

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
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: finding assignments to variables?

Ron Teitelbaum
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


On Mon, Jul 23, 2018 at 7:14 PM, Ralph Boland <[hidden email]> wrote:
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
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: finding assignments to variables?

K K Subbu
In reply to this post by Ralph Boland
On Tuesday 24 July 2018 04:44 AM, Ralph Boland wrote:
> 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
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: finding assignments to variables?

Ralph Boland
In reply to this post by Ralph Boland
> On Tuesday 24 July 2018 04:44 AM, Ralph Boland wrote:
> > 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
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners