The Science of Programming/SwayPresentations/Objects/PublicAndPrivateComponents2

< The Science of Programming‎ | SwayPresentations/Objects

Public and Private Components

We overload assignment so that only variables can appear on the left hand side of the assignment operator.

   function =($a,b)
       var assign = shadowed(:=);
       if (type($a . code) != :VARIABLE)
              "you are only allowed to assign to simple variables");
       $a assign b;

So, anything like:

   x . a = 3;

throws an exception.

Since setters can access the variables directly, they are not affected by this change.

Next Previous Top