[Grace-core] Semantics of object/classes

Andrew P. Black black at cs.pdx.edu
Tue Aug 7 22:24:05 PDT 2012


On 7 Aug 2012, at 12:50, Kim Bruce wrote:

> Responding to Andrew's challenge, here is my first crack at describing the (informal) semantics of objects, classes, and inheritance.  Note that I did not specify the semantics of inheriting from an object as I am not sure which semantics we want -- one based on the initial definition of the object, or one reflecting the dynamic state.

My attempts to describe how object constructors and inheritance should work are on the Wiki:

https://projects.cecs.pdx.edu:8443/~black/NewOOL/index.cgi/wiki/ObjectConstructorDescription
https://projects.cecs.pdx.edu:8443/~black/NewOOL/index.cgi/wiki/InheritanceFromObjects

The style is so different from what Kim sent out that I'm not sure how to compare them.   First, notice that I specified ONLY the semantics of inheriting form an object, since this is the general case, and inheriting from a a class object or inheriting from a newly-created instance of a class are just special cases.   Also notice that I deliberately left the time at which initialization code runs unspecified; we haven't talked about this, but it seems to me that specifying strictly serial execution is a premature pessimization.   Another difference is that I don't write in terms of implementation issues, like when space is allocated, but only about language-level things, like when variables are bound.

Although what I've written on the wiki is what I've come to understand as the semantics of what we now have in Grace, as I write more code, I'm increasingly unhappy with the current formulation of classes.  The problem is that "class side inheritance", to use a Smalltalk-ism, doesn't work right.   If I have a superclass with a constructor method 'makeOne(x)', and I want to inherit from that superclass, then I _have to_ override 'makeOne(x)', because if I don't then I will get the SAME kind of instance from the subclass.   Fixing the class syntax to specify parallel inheritance on the class and instance sides doesn't solve the problem.   And I don't see an easy solution, other than going to Smalltalk-style classes.

I'm now feeling that our Onward! paper was premature.

	Andrew





More information about the Grace-core mailing list