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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, T_FILL_THIS_FORM_SHORT 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 From: adaworks@netcom.com (AdaWorks) Subject: Re: Real OO Date: 1996/03/26 Message-ID: #1/1 X-Deja-AN: 144211049 sender: adaworks@netcom19.netcom.com references: <4if7s5$bfk@ra.nrl.navy.mil> organization: NETCOM On-line Communication Services (408 261-4700 guest) newsgroups: comp.lang.ada Date: 1996-03-26T00:00:00+00:00 List-Id: Robert A Duff (bobduff@world.std.com) wrote: : In article <4if7s5$bfk@ra.nrl.navy.mil>, : Richard Pitre wrote: : >I figured that much. But how it this a limitation? : It's a limitation by comparison with a "pure" OO language, in which : every built-in data type, including things like integers, is a class, : and you can do all the OOP-ish things with them. I didn't say this : limitation is important. This thread started as a discussion of various : differences between Ada and Eiffel, and this is one such difference. Of course there is no inherent limitation in Ada. If one wanted to be absolutely true to the tenets of OOP, one could do something like this: package Number is type Base_Number is abstract tagged private; function "+" (L, R : Base_Number) return Base_Number is abstract; -- also operators for "-", "*", ... etc. private type Base_Number is abstract tagged null record; end Number; Then create concrete number packages for each kind of number. For example, private type Int_16 is range -2**16 .. 2**16 -1; type Integer_16 is new Base_Number with record Value : Int_16; end record; or later, private type R_16 is new Float range ...; type Real16 is new Base_Number with record Value : R_16; end record; Before you exclaim, "Arghhhhhhh" let me suggest that there might be circumstances in which you really want to create your own very restricted variation of the arithmetic operators for the concrete types derived from this abstract class. In fact, this could be the foundation abstract class for the famous Fractions package, the Vector Arithmetic package, or several other packages that service non-standard number models. Furthermore, although we customarily use numbers defined in the Ada LRM, nothing prevents us from approaching number definitions in a more "pure" OOP mode. I realize, such an approach will be rare, but I can imagine safety-sensitive applications where it might make sense to do something such as this. Richard Riehle adaworks@netcom.com -- richard@adaworks.com AdaWorks Software Engineering Suite 27 2555 Park Boulevard Palo Alto, CA 94306 (415) 328-1815 FAX 328-1112