[Grace-core] Annotations

Kim Bruce kim at cs.pomona.edu
Mon Jun 10 22:52:58 PDT 2013


Ah, I knew the spec was out of date on annotations, so didn't check.  If we do indeed have private then I am fine with having that be the default and then public readable is not redundant.  With no private, it is a bit weird to require public and readable as the (implicit) methods are only useful (as readable only) if you know you are eventually going to be overriding them.  That's a tough distinction to sell to novices.

Assuming we do have private, I have found circumstances where I want the implicit readers and writers to have different visibility.  Thus to make things more ambiguous, I would suggest writing public to modify readable and writable.  Thus
      def x  is public readable, public writable = 2
means both are public, while
     def x is public readable,writable = 2
means only the getter is public (though that looks ambiguous).  Is there a better notation (or set of defaults).

Kim



On Jun 10, 2013, at 10:21 PM, Andrew P Black <black at cs.pdx.edu> wrote:

> 
> On 10 Jun 2013, at 16:43, Kim Bruce wrote:
> 
>> Quick question:
> 
> Answer at the bottom:
> 
>> 
>> What is the semantics of the annotation "readable" on defs and vars?
>> 
>> We have talked about having levels of privacy called public, confidential, and private (though I'm not sure if we decided to keep private -- it is currently not supported in minigrace).
>> 
>> Methods are by default public, while defs and vars are by default confidential (private?), unless, as minigrace allows, you annotate the entire file with a different default.
>> 
>> If the default for defs and vars is actually confidential, then it seems to me that readable means the corresponding accessor method should be public.
>> 
>> On the other hand, if the default for defs and vars is private then it makes sense to have readable mean the corresponding method is confidential, while "public readable" would be required to make it public.
>> 
>> I raise the question now as minigrace seems to use the first interpretation (readable means public readable), while James' code for nano-grace seems to assume the second.  We should nail this down one way or the other.  If we use the latter then we need to worry about what "is public, readable, writable" means and whether it differs from "is public, readable, public, writable".
> 
> 
> Surprising as it may seem, this  in the spec!  See §8.7
> 
> — "is readable" and "is writeable" create confidential reader or writer methods for the annotated variable.
> 
> So nanograce follows the spec, and minigrace does not.
> 
> Kim may have a point: now that methods are by default public, it might make more sense for methods created by the 'is readable' and 'is writable' annotations to be public too.   But the argument from encapsulation (also Kim's), says that access to variables should be as restricted as possible, by default, so adding more words to make things more accessible makes sense.
> 
> The spec is out of date wrt the default for methods — it was confidential, and is now public.  We don't at this point have private (lexically bound) methods.
> 
> 	Andrew
> 
> 



More information about the Grace-core mailing list