[Grace-core] [low importance] "as" clauses & super requests

James Noble kjx at ecs.vuw.ac.nz
Sat Mar 9 10:15:43 PST 2013


This should probably be classified as maybe nice to have.

"import" statements (or whatever they are? clauses? directives?)  must be followed by an "as" clause
to give a local name to the module object.

There are a few other places where it would be nice to have local names: we could
*optionally* allow "as clauses" there also.  Scala and OCaml both have syntax for 
doing most of this.

Basically: 

** inherit x as y 

gives a name to the "part object". 

This is mostly useful for multiple inheritance, it would allow directed resends to a particular parent. 
These names are syntactically valid only where "super" is now valid:  only to the left of the dot.

If we really wanted to, we could elide super from the language, and to get it make people say

inherit MySuperclass as super

but that's heading towards being an incantation. This is what OCAML does.

We should at least consider whether we should find some other syntax for super.X  (or y.x where
y is a local parent name).  C++'s super::X is one possibility.  Or not: Self and OCAML both use
y.x for this...



** object x as y  {}
** class x as y    {} 

OCaml goes further and doesn't have a name for "self" - that name must be introduced explicitly.
They don't use "as" syntaxs for it, but I think it makes sense for us, if we want to do this.
These names would be visible only lexically (there's an interesting question whether the
equivaent name of super.outer.outer are acceptable).

With this we could  potentially remove "self" and "outer" from the language: I don't know think
we'd want to remove "self" but removing "outer" could be worthwhile.

Presumably, unlike inheritance "as" names, these names are acceptably anywhere "self" is now - 
that is, anywhere....



More information about the Grace-core mailing list