| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Storing data and code in a Db with LISP-like interface
On 5 May 2006 15:34:48 -0700, Mikito Harakiri wrote:
> Dmitry A. Kazakov wrote:
>> I am free to consider integers a subtype of rationals regardless their >> construction (=representation.) Important here is only that integer >> inherits +, -, * which I wish to reuse as well as the programs written for >> rationals in terms of these operations.
Right, (though inheritance is specific to individual argument/result. You can inherit in one argument and don't in another. I.e. if the result were contravariant it would still be an inherited operation in covariant arguments.)
> But then, you have to redefine arithmetic operations for integers
> anyway.
That depends on what you understand under "redefine." In strict sense each inherited operation is always redefined just because types are different. But for a subtype like integer it can be done automatically using the composition:
Integer."+" ::=
Integer_From_Rational o Rational."+" o Rationals_From_Integers
Because + is closed in integer, Integer_From_Rational will never fail on integer arguments of the composition. I.e. integer is substitutable in rational's +. But direct substitution is a brain damage, what I keep on trying to convince people from both camps.
> So what is the point of inheritance, then?
Modeling is-a: integers might be not rationals, but one might wish to treat them as if they were, to simplify, reuse, generalize things etc.
-- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.deReceived on Sat May 06 2006 - 04:35:56 CDT
![]() |
![]() |