[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: implicit self



> 
> I wanted to better understand the meaning of sending implicit
> self messages, so I tried the following:
> 
>     ( | x <- 4. silly = ( | x <- 2. k: y = (x+y) |
>                                  k: 0 ) | )
> 
> I wondered if sending "silly" to this object should return 2 or
> 4 ( my system returns 2 ) 

Great question Jecel.

Allow me to paraphrase slightly :

(| x     = 4.
   silly = (| x = 2.
              y = (x). |
              y  ).
|) silly

Should this be 2 or 4?  I think you could make a coherent story for 2,
but I think you get a slightly nicer story for returning 4.

So this should be 4 in my book.

Perhaps it seems goofy at first glance, but there must be a distinction
between these 3 concepts:

	The current receiver.                    (self)
	Where message lookup starts.             (thisContext)
	The object holding the looked-up method  (method holder)

(we ran through merging all of these possible pairwise combinations
during the original Self design, but gave up for lack of energy and
insight.)

More explicilty why it should be 4.

   (| y     = (x).
      x     = 4.
      silly = (| x = 2 |
                 y  ).
   |) silly

I hope we all agreee THIS should be 4. And this too...

   (| p*    = (| y = (x)|).
      x     = 4.
      silly = (| x = 2 |
                 y  ).
   |) silly

..and this...

  (| p*    = (| p* = (| y = (x) |)|).
      x     = 4.
      silly = (| x = 2 |
                 y  ).
   |) silly

So in the above examples, we have the method holder moving up and down
the lookup path. But while "silly" is being looked up, and while "y" is
being looked up, the virtual machine has its self marker on the same
object. It would be odd to suddenly slip and let the self marker "drop
down" to the currentContext just becasue the methodHolder is at
currentContext.

Make sense?

	--Randy

(We used to have local methods, does anyone recall how they evaluated?
I hope I am not making a liar out of us. Note, since we allow 
"local parents" we can try in today's system

 (| x    = 4.
   silly = (| p* = (| y = (x) |). 
               x = 2 | 
           y ).
 |) silly


which does in fact return 4.)