Safety (Cont.)
Redefined Attributes and Methods
Attribute driver is redefined for class manager .
|
|
employee IsA person: [
...,
driver: person, ... ]
manager IsA employee, sharesholder: [
...,
driver: employee ]
SELECT domicile FROM p IN person
WHERE p IN ( SELECT driver FROM employee );
|
|
The inner select-expression may supply a heterogeneous set containing objects of type person
and type employee
.
†This heterogeneity will not result in a type violation, because all employees are persons as well and thus all properties of person
—particularly domicile
—apply equally to employee
.
Consider two signatures and implementations for the method deputy
:
deputy ( employee, employee ): BOOLEAN
...
a1.denomination = a2.denomination AND NOT ( a1 == a2 )
deputy ( manager, manager ): BOOLEAN
...
m1.denomination = m2.denomination AND m1.party = m2.party AND NOT ( m1 == m2 )
|
Determines the deputies of all employees:
SELECT a1, a2 FROM a1 IN employee, a2 IN employee WHERE a1.deputy(a2);
|
If
a1
references a manager and
a2
references an employee, and argument of the wrong type will be passed.
ʎɐqǝ uo pɹɐoqʎǝʞ ɐ ʎnq ı ǝɯıʇ ʇsɐן ǝɥʇ sı sıɥʇ
|