[Grace-core] Inheritance and object initialisation

Michael Homer mwh at ecs.vuw.ac.nz
Mon Jul 16 00:14:29 PDT 2012


On Jul 16, 2012 7:00 PM, "Kim Bruce" <kim at cs.pomona.edu> wrote:
>
> Wow, this is a tough test for late on a sunday night ...
> I'll send it now, but try to read it over again tomorrow.
Thanks for the responses. You're right that the extra "object {" inside a
couple of the classes isn't meant to be there. Anything with a class is
meant just to be a class.

I've also put some other corrections inline below.

> >  var tmp
> >  def a = object {
> >    def x = 1
> >    method foo { "hello" }
> >    tmp := self
> >  }
> >  def b = object {
> >    inherits aCreator
> >    method foo is override { "world" }
> >  }
> > Does tmp == a? Does tmp == b? What is tmp.foo?
>
> I assume there is a typo here and aCreator should just be a.
Yes.

> > Or:
> >  var tmp
> >  method aCreator {
> >    object {
> >      def x = 1
> >      method foo { "hello" }
> >      tmp := { foo }
> >    }
> >  }
> >  def b = object {
> >    inherits aCreator
> >  }
> > What is tmp.apply?
>
> "hello" -- is there any other possibility?
There was meant to be an override of "foo" in b, along the lines of the one
returning "world" in the others.
-Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailhost.cecs.pdx.edu/mailman/private/grace-core/attachments/20120716/8f1caa56/attachment.html>


More information about the Grace-core mailing list