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: fac41,c52c30d32b866eae X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,2ea02452876a15e1 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,c52c30d32b866eae X-Google-Attributes: gid1108a1,public From: donh@syd.csa.com.au (Don Harrison) Subject: Re: Real OO Date: 1996/05/06 Message-ID: #1/1 X-Deja-AN: 153231845 sender: news@assip.csasyd.oz references: organization: CSC Australia reply-to: donh@syd.csa.com.au newsgroups: comp.lang.eiffel,comp.lang.ada,comp.object Date: 1996-05-06T00:00:00+00:00 List-Id: Jon, Stepping back to your original example, I'd like to clarify a few things before commenting on it (again). :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); I assume this syntax is correct. That is, you don't have to say Driver'Class? The status of D would be clearer, IMO, if you had to write Driver'Class. : 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); Presumably, Register_Driver does not override the implementation for Vehicle because of RM 6.3.1(15) and 8.3(8,9)? :.... :end Vehicles.Trucks; : : :-- In a client somewhere :-- : D: Driver; : Cd: Car_Driver; : V: Vehicle; : T: Truck; :.... : -- Option 1. : -- : D := Cd; -- Illegal, compile time error : V := T; -- Illegal, compile time error : : -- Option 2. : -- : D := Driver(Cd); -- OK, convert toward root : V := Vehicle(T); -- OK, convert toward root I understand these are view conversions, but am wondering how this can be implemented without reference semantics? : Register_Driver(V, D); -- just fine and no dispatch needed Is this this call statically bound to the implementation for Vehicle? : -- Option 3. : -- : Register_Driver(Vehicle'Class(T),Cd); -- Compile error, no primitive ops ... for type Truck with formal parameter Car_Driver? : -- Option 4. : -- : Register_Driver(Truck'Class(T), Cd); -- Compile error, no primitive ops ... for type Truck with formal parameter Car_Driver? : -- Option 6. : -- : Register_Driver(Vehicle'Class(V), D); -- Fine : Register_Driver(Vehicle'Class(T), D); -- Fine (calls inherited op!!) Shouldn't the first one be: Register_Driver(Truck'Class(T), D); -- Fine :As you can see, you can't get the invalid system stuff in the Ada model. :In particular, you should note that the Truck type has _two_ primitive :operations Register_Driver: : : procedure Register_Driver(V: Truck; D: Driver); -- Inherited from Vehicle : procedure Register_Driver(V: Truck; D: Truck_Driver); -- *New* primitive op And, shouldn't these be: : procedure Register_Driver(V: Vehicle; D: Driver); -- Inherited from Vehicle : procedure Register_Driver(T: Truck; D: Truck_Driver); -- *New* primitive op : :/Jon :-- :Jon Anthony :Organon Motives, Inc. :1 Williston Road, Suite 4 :Belmont, MA 02178 : :617.484.3383 :jsa@organon.com : /// Don. (o o) =-=-=-=-=-=-=-=oOO=-(_)-=OOo=-=-=-=-=-=-=-=-