From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2ea02452876a15e1 X-Google-Attributes: gid103376,public X-Google-Thread: fac41,c52c30d32b866eae X-Google-Attributes: gidfac41,public X-Google-Thread: 1108a1,c52c30d32b866eae X-Google-Attributes: gid1108a1,public From: mbk@caffeine.engr.utk.edu (Matt Kennel) Subject: Re: Real OO Date: 1996/05/01 Message-ID: <4m6l27$sa6@gaia.ns.utk.edu>#1/1 X-Deja-AN: 152339265 references: followup-to: comp.lang.eiffel,comp.lang.ada,comp.object organization: University of Tennessee, Knoxville and Oak Ridge National Laboratory reply-to: kennel@msr.epm.ornl.gov newsgroups: comp.lang.eiffel,comp.lang.ada,comp.object Date: 1996-05-01T00:00:00+00:00 List-Id: Jon S Anthony (jsa@organon.com) wrote: : First, this is a really bad design (even for an example) as it : violates any of the (several) reasonable definitions of is-a : semantics. Second, this example has nothing to do with "legacy" code : or reuse (which is what you claimed was important and I was refering : to). But, let's take it at face value. Neither the a) no b) case is : a problem - not even an issue - in Ada. This is mainly due to the : separation of specific and classwide types. : The example in Ada: : package Drivers is : type Driver is tagged private; : ... : end Drivers; : package Drivers.Cars is : type Car_Driver is new Driver with private; : ... : end Drivers.Cars; : package Drivers.Trucks is : type Truck_Driver is new Driver with private; : ... : end Drivers.Trucks; : with Drivers; use Drivers; : package Vehicles is : type Vehicle is tagged private; : procedure Register_Driver (V: Vehicle; D: Driver); : procedure Renew_Rego_By_Mail (V: Vehicle); : ... : end Vehicles; : with Drivers.Cars; use Drivers.Cars; : package Vehicles.Cars is : type Car is new Vehicle with private; : procedure Register_Driver (V: Vehicle; D: Car_Driver); : ... : end Vehicles.Cars; : with Drivers.Trucks; use Drivers.Trucks; : package Vehicles.Trucks is : type Truck is new Vehicle with private; : procedure Register_Driver (T: Truck; D: Truck_Driver); : procedure Renew_Rego_By_Inspection(T: Truck); : ... : end Vehicles.Trucks; Sather: abstract class $DRIVERS is end; class CAR_DRIVER < $DRIVERS is end; class TRUCK_DRIVER < $DRIVERS is end; class VEHICLE is register_driver(d:$DRIVER); end; class CAR is include VEHICLE; register_driver(d:CAR_DRIVER); end; class TRUCK is include VEHICLE; register_driver(d:TRUCK_DRIVER); end; Though I'd personally not rely on the punning, and would rather do it with a distinct name. class VEHICLE is register_driver_if_valid(d:$DRIVER):BOOL; -- return success end; : jsa@organon.com