previous up next
Go backward to Kinds of Polymorphism
Go up to Top
Go forward to Parametric Polymorphic Operations
RISC-Linz logo

Overloaded Operators

Pascal addition expression.

E[[E1+E2]] = lambda e.lambda s.
    cases (E[[E1]]e s) of
        isNat(n1) -> (cases (E[[E2]]e s) of
            isNat(n2) -> inNat(n1 plus n2)
            ...end)
        ...
        [] isRat(r1) -> (cases (E[[E2]]e s) of
            ...
            [] isRat(r2) -> inRat(r1 addrat r2)
            ...end)
        ...
        [] isSet(t1) -> ...inSet(t1 union t2) ...
        ...
    end

Pre-execution analysis -> actual operation can be determined at compile-time.


Author: Wolfgang Schreiner
Last Modification: December 18, 1997

previous up next