[Grace-core] Variables as methods
Timothy Jones
Timothy.Jones at ecs.vuw.ac.nz
Tue Aug 13 15:55:43 PDT 2013
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
More information about the Grace-core
mailing list