declare PlanePoint % PlanePoint is a function which takes no input, and outputs a record % d with three fields, each of which are procedures. % % We return a record so that we can use the '.' syntax, mimicking OO % systems. % % The fields are procedures to implement data encapsulation, by % preventing direct access to X and Y. fun {PlanePoint} X Y Translate GetX GetY X = {NewCell 0} Y = {NewCell 0} fun {Translate Xdist Ydist} X := @X + Xdist Y := @Y + Ydist end fun {GetX} @X end fun {GetY} @Y end in d(translate:Translate getX:GetX getY:GetY) end declare P1 R P1 = {PlanePoint} R={P1.translate 1 2} {Browse {P1.getX}} {Browse R}