[SDL Forum Society - Logo] Tutorial on SDL-88
Belina, Hogrefe (edits Reed)

6.5 Inheritance

Back Home Up Next

With the inheritance concept it can be avoided to re-specify something which has already been specified elsewhere. With inheritance, all values, some or all operators and all equations are inherited by a child sort from a parent sort. With the keyword ADDING, further literals, operators and equations can be added to the child sort. The inherited operators and literals can be renamed to avoid confusion

Suppose we have a sort sorl which is defined as follows:

NEWTYPE sor1
LITERALS li1, li2;
OPERATORS
        op1:...
        op2:...
        op3:...
AXIOMS ...
ENDNEWTYPE;

With this sort a new sort sor2 can be defined which uses the operators op1 and op2, but renames op2 into opA and adds a new operator opB and a literal liA:

NEWTYPE sor2
INHERITS sor1
        OPERATORS (op1, opA = op2);
ADDING
        LITERALS liA;
        OPERATORS opB:...
        AXIOMS ...
ENDNEWTYPE;

It is not necessary (or allowed) to specify the literal operators that are inherited: they are all inherited by default.

The frequent case that all operators should be inherited, can be specified by

INHERITS ...
OPERATOR ALL

Back Home Up Next

Contact the webmaster with questions or comments about this web site.
Copyright 1997-May, 2013 SDL Forum Society