Pseudovariables?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Pseudovariables?

Casey Ransberger-2
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? Does a pseudovariable reference a first class object? Is the thing known as true an object, is this a pseudovariable? 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. Does this confuse other people too?

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?

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

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


Reply | Threaded
Open this post in threaded view
|

Re: Pseudovariables?

Nicolas Cellier
Take a look at Parser.

Nicolas

2010/4/15 Casey Ransberger <[hidden email]>:

> 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? Does a pseudovariable reference a first class
> object? Is the thing known as true an object, is this a pseudovariable? 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. Does this confuse other people too?
> 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?
> What if I wanted to introduce a synonym for super, say: mom? :P
> I've been rummaging today trying to figure out where these things live and
> how they work. Any guidance would be much appreciated!
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Pseudovariables?

Bert Freudenberg
In reply to this post by Casey Ransberger-2
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 -