[Grace-core] Super-Outer-Objects: What does your language (gBeta/Newspeak/Scala/Java…) do with this? What should Grace do?

Kim Bruce kim at cs.pomona.edu
Tue Nov 20 11:56:45 PST 2012


I agree with Andrew's answers and reasoning.  The call of "pathological in B's foo method is really outer.pathological, which is statically bound to A.pathological.

A somewhat tricker question might involve an D inheriting from A that overrides pathological.  What will D.B.foo print?  The answer differs depending on whether we understand "pathological" in foo as being outer.pathological or A.pathological.  I'm a bit worried about bizarre interactions and difficulties if it is bound to outer.pathological.  Thus an excess of caution leads me to bind it to A.pathological, even though that limits expressiveness.  The other choice leads us awfully close to family polymorphism, which has its own issues.

Kim



On Nov 19, 2012, at 9:35 AM, Andrew P. Black wrote:

> 
> On 19 Nov 2012, at 2:26, James Noble wrote:
> 
>> What do other languages do?     What should Grace do?  
> 
> I'll add some line numbers of reese of reference.
> 
> 
>> 1.   #pragma DefaultVisibility=public
>> 
>> 3.   def A = object {
>> 4.       method pathological {print "A-pathological"}  
>> 5.       def B = object {
>> 6.            method foo {pathological}
>> 7. 	   }
>> 8.   }
>> 
>> 10.  def C = object { 
>> 11.            inherits A.B
>> 12.            method pathological {print "C-pathological"}
>> 13.   }
>> 
>> 15.  A.pathological
>> 16.  A.B.foo
>> 17.  C.pathological
>> 18.  C.foo
> 
> Here's what I think Grace should do, and why.
> 
> The "receiverless"   request pathological on line 6 is potentially ambiguous: it might mean self.pathological, or it might mean A.pathological (or, outer.pathological, depending on whether A is in scope inside the definition of A, which is a separate issue.)  In this case the ambiguity is easy to resolve; it can't mean self.pathological, because there is no method pathological in B, so it must mean A.pathological.
> 
> Hence, line 15 and 16 both print "A-pathological".
> 
> When object C inherits A.B on line 11, it gets the method foo (only) from B.   (A has an auto-generated method B because of the  #pragma DefaultVisibility=public; this seems to be irrelevant to the example, since B could just as well be declared as a method directly, but perhaps James will explain why he did it this way.)   On line 12, object C is also given its own method pathological; not that this is not an override, but a new method.
> 
> So C.pathological prints "C-pathological", whereas C.foo requests the foo method on line 6, which in turn requests A.pathological, which prints 
> "A-pathological".
> 
> 
> _______________________________________________
> Grace-core mailing list
> Grace-core at cecs.pdx.edu
> https://mailhost.cecs.pdx.edu/mailman/listinfo/grace-core

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailhost.cecs.pdx.edu/mailman/private/grace-core/attachments/20121120/c7348b0e/attachment.html>


More information about the Grace-core mailing list