[Grace-core] minigrace oddness

Kim Bruce kim at cs.pomona.edu
Mon Jun 30 12:49:31 PDT 2014


No on internal names -- too confusing.

However, you point out real problems with giving everything a name.

None of this is actually crucial (as James points out, minigrace doesn't use outer at all).

Because of the situation I ran into where I wanted something to look very much like a built-in method/control construct, I fell into the trap of overriding something unexpectedly.  (Reminder:  We had originally planned to make that illegal for reasons like this -- perhaps we can at least emit a warning and perhaps require an annotation.)

It feels odd to me that super and outer have quite different semantics, hence my suggestion to make them parallel (though with a slightly different name:  outer+).  However, it's not worth a lot of our time for something that won't come up often.

Kim



On Jun 30, 2014, at 2:19 AM, James Noble <kjx at ecs.vuw.ac.nz> wrote:

> On 30/06/2014, at 12:27 pm, Andrew P Black <black at cs.pdx.edu> wrote:
> 
>> Ugh!  Why not give the object a name?
> 
> Short answer - you can always write 
> 
>    def x = object { ... } 
> 
> but it doesn't always do what you want (in that x.foo will make a
> normal "external" request on x, coming down from x's outside,
> not an "outer" request on x, coming up from x's inside. 
> 
> 
> Longer answer: other constructors (literals) don't have names.
> But I guess we could add internal names for objects. 
> The syntax is obvious (from OCAML):
> 
> object myname is annotations {
> 
> }
> 
> 
> where "myname" can be used as an alias for "self" inside the object,
> and the appropriate number of outer"s in objects nested inside.
> 
> But this means that the syntatic form of a message request "myname.foo"
> *isn't* a "normal" request when myname is one of these nested names,
> it has to have the semantics of an "outer" request.    
> That's confusing (although a further syntax would be to force people to write 
> outer(myname) or outer.myname which have the virtue of not looking like
> normal method requests
> 
> I also think that people will want to write code referencing myname, i
> i.e. that the named constructor also induces a declaration like 
> 
> def myname = object myname { ... } 
> 
> as in Scala.   (or perhaps they won't - I don't think OCAML does this,
> and it does have named objects and named classes).   Do we allow this? 
> 
> At which point, if anything, I quite like generalising "outer" to work like "super";
> you're only allowed one "outer" (you can't write outer.outer or super.super);
> and outer *must* be followed by a request, that is just looked up lexically.
> If you want a reference to an outer object to hand out, use a def.
> If you want to call a confidential method that's lexically shadowed, 
> outside you, you can't --- just as in Smalltalk, you can't call a 
> normally requests a method from some super-super class that
> e.g. your superclass has overridden.
> 
> one point seems to be that minigrace itself doesn't use "outer." at all
> so we could change this without the existing compiler relying on it...
> 
> J
> 
> 
> _______________________________________________
> Grace-core mailing list
> Grace-core at cecs.pdx.edu
> https://mailhost.cecs.pdx.edu/mailman/listinfo/grace-core




More information about the Grace-core mailing list