[Grace-core] Dialect encoding

James Noble kjx at ecs.vuw.ac.nz
Sun Jul 29 21:32:44 PDT 2012


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

newspeak's encoding (actually not an "encoding") is based on classes...

> 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.

would something like

object {
  def newObject = object {
    inherits … 
 }
}

work just as well? 
the point is that a method establishes an additional dynamic scope.

> 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.

so that's good, indeed that's what we want!

> 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.

I think that's what we have to decide! 

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

Sure. And that's good: we don't want to add "dialect" as a first-class construct
unless we absolutely have to!

James


More information about the Grace-core mailing list