[Grace-core] Super-Outer-Objects: What does your language (gBeta/Newspeak/Scala/Java…) do with this? What should Grace do?
Andrew P. Black
black at cs.pdx.edu
Mon Nov 19 09:35:57 PST 2012
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".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailhost.cecs.pdx.edu/mailman/private/grace-core/attachments/20121119/547ec3f0/attachment.html>
More information about the Grace-core
mailing list