[Grace-core] Dialect encoding

Timothy Jones tim at zimothy.com
Sun Jul 29 20:05:53 PDT 2012


> I don't know - there seem to be two different things going on here. 
>  - interpreting modules with inner & outer nested objects
>  - putting a method in between them
>
> what are the benefits or liabilities of doing it this way?

Think of it like the Newspeak encoding, except an instance is
immediately instantiated.

The method has to be there just because you can't return an object from
inside an object constructor, and we have to return the inner object.
I'm not saying that a dialect statement has to be directly translated
into this format, but it shows that it is possible to achieve the same
effect just with objects.

I don't think it's possible to achieve this without writing it out in
full, though: you can't pass the inner object into a method because it
has to be directly nested inside the outer object. The dialect statement
would need to be built in.


> Why can't we inherit directly - or if we do want to nest, nest directly?
Using inherits attaches the methods to the object, which means clients
of the module can use them as well. I'm under the impression that
dialect is meant to avoid this.

Nesting explicitly obviously achieves the same effect. This encoding is
just an explanation of the sugar (or magic) that dialect provides.

Tim




More information about the Grace-core mailing list