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

Panu Suominen panu.suominen at iki.fi
Tue Mar 25 06:50:57 EDT 2014


What do you mean operates at higher level?

>From Wikipedia:
"In computer science <https://en.wikipedia.org/wiki/Computer_science>,
*reflection* is the ability of a computer
program<https://en.wikipedia.org/wiki/Computer_program> to
examine (see type
introspection<https://en.wikipedia.org/wiki/Type_introspection>)
and modify the structure and behavior (specifically the values, meta-data,
properties and functions) of the program at
runtime<https://en.wikipedia.org/wiki/Run_time_(program_lifecycle_phase)>
."

Most things are much harder to do in Java than in Smalltalk but I don't
know if the level differs so much. For example method substitution is not
so standard VM feature in Java.



2014-03-25 12:42 GMT+02:00 Sergi Reyner <sergi.reyner at gmail.com>:

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


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


More information about the Pharo-users mailing list