[Grace-core] satanic class encoding

James Noble kjx at ecs.vuw.ac.nz
Sun Jul 29 03:23:22 PDT 2012


Hi all

so on friday afternoon, waiting for the accreditation results to come out,
I talked to Tim & Michael and as part of that discussion we came up with
this alternative "satanic" encoding of objects-as-classes.

Basically:

> object {
>    inherits c.new(x)
> }
> 

gets rewritten to: 

> object {
>    inherits c.new(x) soldSoulTo(self)
> }

This is "closing the knot" as Andrew put it.

Then a class
> 
> class c.new(x) {
>    ...
>    self.someMethod
> }
> 
==>

gets rewritten to something like 

> def c = object {
>    method new(x) {
>        object {
>            inherits new(x) soldSoulTo(self)
>        }
>    }
>    method new(x) soldSoulTo(satan) {
>        object {
>            ...
>            satan.someMethod
>        }
>    }
> }

where *every* explicit or implicit reference to "self" in the top level of the class
gets rewritten to "satan".   This is horrible, but it should initialise superobejcts
"correctly".  It would let us preserve the classes-as-objects story, but at the 
cost of making them significantly more complex (unless we added optional
arguments as well) .  

James


More information about the Grace-core mailing list