[Pharo-users] Java "this" against our "thisContext"

Camille Teruel camille.teruel at gmail.com
Tue Mar 25 06:41:29 EDT 2014


On 25 mars 2014, at 11:30, Benjamin <benjamin.vanryseghem.pharo at gmail.com> wrote:

> Within an instance method or a constructor, this is a reference to the current object — the object whose method or constructor is being called. You can refer to any member of the current object from within an instance method or a constructor by using this.
> 
> from: http://docs.oracle.com/javase/tutorial/java/javaOO/thiskey.html
> 
> thisContext in smalltalk points to the execution context of the method being currently evaluated.
> So definitely this and self are the “same” (as long as we do not talk about inner classes)
> 
> thisContext does not exist in Java AFAIK

You can get a reification of the stack with simple introspection (get the method, class or file name and the line number) with Thread.currentThread().getStackTrace()
But this is far from the fully reflective Smalltalk stack and the advanced manipulations it enables. 

> 
> Ben
> 
> On 25 Mar 2014, at 11:27, Sergi Reyner <sergi.reyner at gmail.com> wrote:
> 
>> Hi everyone,
>> 
>> I had a pretty heated IRC debate yesterday about how Smalltalk´s reflection facilities are superior to those of Java, in the sense that they operate at a higher level (I started it pasting one of those crazy snippets that got posted to the list xD). It somehow slowly degenerated into someone trying to convince me that Java's "this" operator is equivalent to "thisContext", instead of "self".
>> 
>> My intuition says that´s wrong, but I´d very much like someone familiar with both to offer an explanation to this poor unenlightened person :D
>> 
>> Cheers,
>> Sergi
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20140325/75b66c61/attachment.html>


More information about the Pharo-users mailing list