[Grace-core] Variables as methods

Kim Bruce kim at cs.pomona.edu
Tue Aug 13 17:15:49 PDT 2013


Andrew, James, and I agree to Tim's proposal.

Kim



On Aug 13, 2013, at 3:55 PM, Timothy Jones <Timothy.Jones at ecs.vuw.ac.nz> wrote:

> If every variable is automatically a confidential method on the surrounding
> object, then defining annotations to make reading and writing that variable
> publicly available is significantly simpler.
> 
> Consider this object definition:
> 
>> object {
>>  // Confidential getter
>>  def a = 1
>> 
>>  // Public getter
>>  def b is public = 2
>> 
>>  // Confidential getter and setter
>>  var c := 3
>> 
>>  // Public getter and confidential setter
>>  var d is readable := 4
>> 
>>  // Confidential getter and public setter
>>  var e is writable := 5
>> 
>>  // Public getter and setter
>>  var f is public := 6
>> }
> 
> These variables enumerate all of the possibilities.  Annotating a var as
> readable, writable is equivalent to declaring it public.
> 
> If you really need private variables, just declare them outside the object.
> 
>> method newObject {
>>  def x = 1
>>  object {
>>    method number { x }
>>  }
>> }
> 
> -- 
> Tim
> _______________________________________________
> 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