Example:

Object contains two numbers, set by constructor

Message "max" returns greater

   "   "min"      smaller

pair(x,y) =

(msg) Þ msg=="max"? max(x,y):

         msg=="min"? min(x,y):

  concat("message", msg, " not understood");

Instantiations:

a =    pair(3,5);

b =    pair(-5,19);

         :

         :

b("max") ==> 19

Link to source file objects.rex.

To Next Slide To Previous Slide To Contents