[Grace-core] Inheritance and object initialisation
James Noble
kjx at ecs.vuw.ac.nz
Thu Jul 19 02:28:39 PDT 2012
On 18/07/2012, at 06:23 AM, Kim Bruce wrote:
> As a side note, I like the idea of being able to write myObject.type for a singleton type.
yes we want something like that. Currently the spec is ambiguous/wrong.
it talks about just mentioning zeroary methods in type expressions as
singleton types of the object those those types name. That's a mess
for a range of reasons.
It talks about writing LiteraPattern.new(o) for a pattern matching just "myObject".
That's better, but this pattern should basically be the same as the singleton type
for that object.
the problem with o.type for a type is that o.type can mean at least three things:
- a reification of the "structural" type of o - kind of like a type mirror I guess.
- a refication of the static type of o
- a reification / type representing of the singleton type of o
either way, if we want o.type to mean anything it should be (yet another) thing added to graceObject,
yet more protocol accessible on every object.
I seem to recall saying we'd write
- staticType(o) to mean the static structural type of o;
- o.dynamicType to mean the dynamic type of o --- not sure I like this now
I wonder if both of these should be off in mirrors or some other (optional) module?
In that light, I'd now prefer writing singleton(o) for a singleton pattern/type that matches "o"
writing:
> type OptionNode = Node | emptyNode.type
so my preferred expression for this is to write
> type OptionNode = Node | emptyNode
because I think this looks nicer, and then emptyNode should be a self-matching
(aka "autozygotic") object --- it matches itself, perhaps by inheriting from
abstractSingleton (or something). Hopefully the static type system can also
work this out properly...
James
More information about the Grace-core
mailing list