[Grace-core] Visibility of variables and constants in Objects

James Noble kjx at ecs.vuw.ac.nz
Wed Jul 3 02:13:42 PDT 2013


> In the following example, is the use of p in doit a method request or a use of the parameter of new?   We have to have a rule about this, and we have to teach it, and it's embarrassing that the language is so complicated that I'm not sure what it is!  

this is currently caught by "no shadowing" - the program should be rejected.

but yes, this example also cuts to why we need a simple, consistent rule about how we resolved implicit requests. I don't want that rule - or the behaviour - to change if  "method p {1}" were to be replaced by "def p = 1" or "var p := 1" or "var p =1 is public, readable" (or is public, or is readable)

> But whether x is always dynamically or always lexically bound won't fix this problem.  The only "fix" would be to get rid of lexical binding altogether, including in blocks that capture their environment, and including parameters.  None of us thinks that this would be a good idea!

well no... or we could switch to a selfish/newspeakish model,
where method & block extents are reified as runtime objects, 
and those objects nest (NS) or inherit (Self) so that 
we get the bindings we want. 


>     object {
>         method new(p) {
> 	    object {
>                 def x = 56
> 		method p {1}
>                 method doit(q) {
>                     (p + x) ^ q
>                 }
>             }
>         }
>     } 


More information about the Grace-core mailing list