Class of method

classic Classic list List threaded Threaded
2 messages Options
Garret Raziel Garret Raziel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Class of method

Hi,
I have read that method of object is object itself. So my question is, how can I send message to that object? Is there for example possibilty to send message to the method to decompile itself and show its code? What is method subclass of?

Jan

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Levente Uzonyi-2 Levente Uzonyi-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Class of method

On Wed, 4 Jan 2012, Garret Raziel wrote:

> Hi,
> I have read that method of object is object itself. So my question is, how
> can I send message to that object? Is there for example possibilty to send
> message to the method to decompile itself and show its code? What is method
> subclass of?

Copy this snippet to a Workspace and you'll find the answer to all of your
questions:

"Evaluate the following two lines."
theObject := 42. "Just an object, could be anything."
method := theObject class lookupSelector: #factorial. "Since we know that the object is an integer, and we know that integers understand a message named factorial, therefore we can fetch the method for that name."
"Then print the following lines one by one."
method getSource. "Print this to get the exact source code."
method decompileString. "Print this to get the decompiled source code."
method class. "Print this to get the class of the method"


Levente

>
> Jan
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Loading...