[Grace-core] Dialect Design Proposal

Michael Homer mwh at ecs.vuw.ac.nz
Wed Nov 28 16:52:05 PST 2012


On Thu, Nov 29, 2012 at 1:00 PM, Timothy Jones <tim at zimothy.com> wrote:
> tl;dr Make constructors the fundamental OO concept in Grace.
>
>> I've had occasion to learn quite a lot about JavaScript, and I don't
>> believe that JavaScript has anything Grace should emulate. I believe
>> the following summary is accurate and fair:
>>
>>   Idiomatic JavaScript uses class-based inheritance.
This is not really true.
> I think Javascript is a lesson in how to implement useful and
> interesting ideas poorly. The very fact that we *can* use class-based
> inheritance in a prototype-based language should be alerting us that
> there is something useful in its feature set.
Yes.
> So object inheritance uses Self-style delegation, but if the
> construction of the super object will be at the same time as the
> inheriting instance (which is made explicit by the super method being a
> constructor), then the chain is set up *before* executing any code in
> the constructor itself. Conceptually they all use the same style of
> inheritance, the constructor just swaps the order of the setup to ensure
> that self is bound as expected. It's like what Javascript does, but
> without the incredibly awful setup of the prototype chain before any
> object is actually instantiated.
>
> This satisfies our goals! Objects can inherit from objects, classes can
> inherit from classes, objects can inherit from classes, classes can even
> inherit from objects, they're all defined in terms a fundamental
> concept, and inheriting from an object in no way affects the identity of
> that object or any other objects inheriting from it. Inheritance works
> the way you expect it to work coming from pretty much any other OO
> language
>
> I eagerly await your input on how this solution that appears to solve
> all of our problems is somehow utterly flawed.
What about field initialisation?
-Michael


More information about the Grace-core mailing list