[Grace-core] [Minigrace] inheritance and closures

James Noble kjx at ecs.vuw.ac.nz
Tue Jun 5 02:38:15 PDT 2012


On 5/06/2012, at 13:42 PM, Michael Homer wrote:

> I think so, .... But conceivably it could be the right thing to
> do (it is lexical scope - the unqualified call without "self." is more
> ambiguous).

I think it's a bug.
In general  saying
> x
and 
>  {x}.apply

should mean the same thing.
this is another justification for "return"
always returning from the containing method

J

> print "Hello, world!"
> 
> class Super.new {
>   method foo {print "foo in Super"}
>   method bar {self.foo} 
>   method baz { {self.foo}.apply }
> } 
> 
> print "in Super"
> def s = Super.new 
> s.foo
> s.baz
> s.bar 
> 
> 
> 
> class Sub.new {
>   inherits Super.new
>   method foo {print "foo in Sub"}
> } 
> 
> print "in Sub"
> def t = Sub.new 
> t.foo
> t.baz
> t.bar 
> 


More information about the Grace-core mailing list