Operators can be overloaded by defining them as messages.
(vector (list (x integer)
(y integer))
msg ((+ vectorplus open t
argtypes (vector))))
(gldefun vectorplus ((v1 vector) (v2 vector))
(a (typeof v1) with x = (x v1) + (x v2)
y = (y v1) + (y v2)))
The use of typeof lets the code use a type derived
from an argument.
(gldefun t7 ((u vector) (v vector)) u + v)
result type: VECTOR
(LAMBDA (U V) (LIST (+ (CAR U) (CAR V))
(+ (CADR U) (CADR V))))
Contents    Page-10    Prev    Next    Page+10    Index