[Grace-core] Inheritance and object initialisation

Michael Homer mwh at ecs.vuw.ac.nz
Mon Jul 16 03:36:18 PDT 2012


On Mon, Jul 16, 2012 at 9:29 AM, Michael Homer <mwh at ecs.vuw.ac.nz> wrote:
> Hi,
> I've been trying to deal to a bug Kim reported a while back and maybe
> some others, but in doing so I've realised I don't understand what the
> semantics of inheritance are supposed to be. My instincts for
> different cases aren't consistent with each other. I'm going to give
> some examples, and then generally questions on what particular
> expressions evaluate to afterwards to clarify.
Here are a few more examples that I forgot:
  def a = object {
    var x := 1
  }
  a.x := 2
  def b = object {
    inherits a
    def y = 2
  }
What is b.x?

  def a = object {
    def x = object {
      inherits a
      def y = 1
    }
  }
Does a.x == a.x.x?

  method aCreator(blk) {
    object {
      method y { 1 }
      def x = blk.apply
    }
  }
  def b = object {
    inherits aCreator { self.y }
    method y { 2 }
  }
What is b.x?
-Michael


More information about the Grace-core mailing list