[squeak-dev] Pseudovariables?

Bert Freudenberg bert at freudenbergs.de
Thu Apr 15 06:31:59 UTC 2010


On 15.04.2010, at 03:47, Casey Ransberger wrote:
> This is something I've been fishing through the image for for awhile, and I haven't figured it out. I'm going to give in and ask.
> 
> What's a pseudovariable?

Strictly speaking self and thisContext, whose value is not fixed but differs even though it's never assigned to. "super" is an alias for "self". 

Also true, false, nil are called pseudo variables, though they aren't "variable" at all.

Syntactically all these are variables, but you can't store into them.

> Does a pseudovariable reference a first class object?

Like every other variable, sure.

> Is the thing known as true an object, is this a pseudovariable?

Yes, true is an object, the singleton instance of True.

> In the comment for True, it says "most of these methods are not sent as real messages" and "redefining these methods here will have no effect." I don't see prims there, though.

Some message sends are rewritten by the Compiler. E.g., an ifTrue: is not really sent but compiled to a conditional jump bytecode.

To see this, write a method that uses an ifTrue: or whileTrue:, then look at the byte code (click on the method selector in the right-hand list, choose "what to show").

>  Does this confuse other people too?

Not me :)

> What if I had an idea for a new pseudovariable that would change the world. Like, if I wanted to create a new pseudovariable and call it 'rosebud'; where would I put it?

In the Parser / Compiler.

> What if I wanted to introduce a synonym for super, say: mom? :P 

Same place.

> I've been rummaging today trying to figure out where these things live and how they work. Any guidance would be much appreciated!


Learning how stuff gets compiled and executed is really fun. Maybe start with the Squeak Blue Book (edited by Guzdial and Rose). I'm sure there are other texts about it but I'm sure others could weigh in.

- Bert -


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100415/6ea86c2a/attachment.htm


More information about the Squeak-dev mailing list