[Grace-core] Semantics of object/classes

Kim Bruce kim at cs.pomona.edu
Wed Aug 8 16:33:21 PDT 2012


On Aug 8, 2012, at 3:38 PM, James Noble wrote:

>> Looks good, and corresponds to the semantics I have in mind for classes.  (Again, I provided semantics for inheriting from classes as that is the case that is the most important to me.)  
> 
> right.   
> I'm still wondering if Andrew can commit himself that the "unified self" is at least what we want
> for _class inheritance_ - even if we get it through some other mechanism.

I hope so.
> 
>> Your code in "The longer story" doesn't actually execute as we don't have ";" in the language.  You would need to write 
> 
> I haven't tried executing any of that code, but I think we do have ";"! 

Not in the web based Grace
> 
>> def x = {
>>               print "1"
>>               1
>>             }.apply
>> 
>> to get that effect.
>> 
>> For me, the key decision here is the one expressed in "What about side effects", that is, that the meaning of "self" is of the new object being defined.
> 
> right. 
> 
>> By the way, I get worried when I see discussions of following up the inheritance chain to execute constructor code, especially when combined with the use of "super".  It is very important that super.m be resolved statically, not dynamically like self.
> 
> the spec currently says
> 
>> In over- riding methods, method requests with the pseudo-receiver super request the prior overridden method with the given name from self. Note that no “search” is involved; super-requests can be resolved statically, unlike other method requests.

I'm not sure "prior overridden method" is completely accurate.  One could write super.m in a method n, even if m wasn't overridden (though it would be weird to write super.m instead of m in that circumstance).  I would likely say:
"method requests with the pseudo-receiver super request the method with the given name from the inherited class."

On a related note, using the concatenation model for resolving super is likely hard to get right without some twisting of definitions.  You couldn't define super.m as just looking for the second definition of m in the list.

> 
> which I think is close enough to the right thing for now (feel free to make it better!)
> and is what minigrace now does.
> 
> James
> 
>>> 
>>> James
>> 
>> 
> 



More information about the Grace-core mailing list