[Grace-core] Inheritance and Template Objects

James Noble kjx at ecs.vuw.ac.nz
Sat Apr 6 17:11:50 PDT 2013


On 6/04/2013, at 20:06 PM, Kim Bruce wrote:

> To me, all of this is more easily done with classes, and perhaps the distinction between kinds of operations is clearer with a slight tweak to the syntax.

well I think so too, on the whole.

> If we really want to inherit from it, then I understand that Andrew would either implicitly or explicitly define a template that would be associated with ob.  To me, it seems simpler to at that point just refactor and write

yep...

> class C.m(a,b) {...}
> 
> Can I also define
> 
> class C.n(a,b) {...}  ?
> 
> That is I use the same name for the class, but different names for constructors.  In general, C.m and C.n might return very different types of objects, but I could imagine this being a useful way of getting multiple constructors for a class generating a fixed type:

Currently no - this is what I was calling "packaging" in one of my long emails.
Because we are structural, it's just a convenience to make an object containing
a named method.   We could change the "class" form to make a method rather
than an object with a method in it, or to allow both

> Now classes aren't themselves objects, but I could imagine these definitions as giving rise to 
> object Point {
>      method at(x,y) {object {...}}
>      method origin {at(0,0)}
> }

Right - or you can just define that now in various ways...

> Because I tend to think in a class-centric way, I would likely only want to define inheritance on the class level rather than doing it in the factory object, though I suspect some of you might want to be able to handle inheritance inside there as well.

I quite like the encoding story, however it ends up being told, given we look like having
both classes and object constructors.  The simplest way to tell it (ironically?) seems to
be with classes...

> With multiple constructors, the inheritance could be done separately on all classes/constructors or it could be done just once:

Yep. 
> 

> To me, all of this is simple and familiar.  The semantics is exactly what we've been talking about, with constructor code of superclasses that are inherited from being run on objects created from subclasses.

right.  That's what I was trying to capture with my short email yesterday

James


More information about the Grace-core mailing list