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

Sergi Reyner sergi.reyner at gmail.com
Tue Mar 25 06:42:51 EDT 2014


2014-03-25 10:30 GMT+00:00 Benjamin <benjamin.vanryseghem.pharo at gmail.com>:

> 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)
>

Yeah, that part I truly understand.I do know enough Java and Smalltalk to
understand that "this" and "self" are equivalent (topic which somehow
evaporated from the debate, and replaced with "this is the same and
thisContext because [unintelligible Java code]".


> thisContext does not exist in Java AFAIK
>

That´s exactly what my intuition led me to. But when I tried to explain
that I, too, don´t think that Java has a concept of "thisContext" I was
presented with this:

Field a = sun.misc.VM.class.getDeclaredField("directMemory");
a.setAccessible(true);
a.get(null);


Which, after some investigation, and as far as I understood, looks to me as
if all it does is retrieve what "this" points to.

It´s not really relevant because what I was arguing is that Smalltalk
reflection operates at a higher level, which that piece of code proves
pretty nicely, but since we got there I´d like to understand everything
argued.

Cheers,
Sergi

PS: Note that I´m not trying to win an internet debate, but simply to
understand :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20140325/502a9f90/attachment.html>


More information about the Pharo-users mailing list