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

Lex Spoon lex at lexspoon.org
Wed Aug 8 16:33:19 PDT 2012


On Wed, Aug 8, 2012 at 6:55 PM, James Noble <kjx at ecs.vuw.ac.nz> wrote:
> This code prints "o" twice.   Is that what it should do?
>
> In particular, shouldn't the call "runi" print "i"

I might be reading it too fast, but I would think two o's is the
correct output. I'd interpret the bare "m" expressions to be
equivalent to "theCorrectEnclosingSelf.m". In the outer access to "m",
"theCorrectEnclosingSelf" is just "self". For the inner access, I'm
not sure how you'd write it in Grace, but it is the "self" of the
outer object. In both cases, the call to "foobles" then resolves to
the method on the outer object.

Looking at it another way, consider the call to "foobles" that occurs
in m. Statically, this call resolves to the method "foobles" that is
in the outer object. Dynamically, therefore, the call should resolve
either to that same method or to some method that overrides it.
However, nothing overrides it.

Lex


More information about the Grace-core mailing list