[Grace-core] nesting - what should "self" be when invoking lexically scoped methods

James Noble kjx at ecs.vuw.ac.nz
Wed Aug 8 16:55:46 PDT 2012


> I agree with Lex.  The two versions of foobles are unrelated and the call of m in method runi is really to outer.m

so, first of all, that code is I think technically illegal in Grace - because the inner "foobles" shadows the outer "foobles".
Originally the run methods also shadowed, but I renamed them...

Then the question is: when an implicit call resolves to a lexically scoped method, where does the *receiver* resolve to?  
To the outer object, or the inner one?

I always assumed outer, but looking at the Newspeak spec, I think it implies such a call does not change the receiver.

Someone should check Newspeak, and see what JavaScript does, etc. 

James

> def o = object {
>    method foobles { print "o" }
>    method m { foobles }
>    method runo { m }
> 
>    def i = object {
>        method foobles { print "i" }
>        method runi { m }
>    }
> 
> 
> }
> 
> o.runo
> o.i.runi 


More information about the Grace-core mailing list