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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-11 21:00:19 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: amir@iae.nsk.su (Amir Yantimirov) Newsgroups: comp.lang.ada Subject: Re: Is the Writing on the Wall for Ada? Date: 11 Sep 2003 21:00:18 -0700 Organization: http://groups.google.com/ Message-ID: <5115eb96.0309112000.339b8258@posting.google.com> References: <3F5F7FDC.30500@attbi.com> <3F6079A9.6080108@attbi.com> NNTP-Posting-Host: 81.1.215.198 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1063339219 6031 127.0.0.1 (12 Sep 2003 04:00:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 12 Sep 2003 04:00:19 GMT Xref: archiver1.google.com comp.lang.ada:42398 Date: 2003-09-12T04:00:19+00:00 List-Id: "Robert I. Eachus" wrote in message news:<3F6079A9.6080108@attbi.com>... ... > type Cartesian is record X,Y: Float; end record; > > and the Polar type: > > type Polar is record R, Theta: Float; end record; > > we could even have a pair of procedures: > > procedure Set_Point(P: Cartesian; X,Y: Float) is > begin P := (X,Y); end Set_Point; > > procedure Set_Point(P: Polar; R,Theta: Float) is > begin P := (R, Theta); end Set_Point; > > But for the union type, at least one of those implementations has to be > wrong. For example, if the ACTUAL representation is cartesian, we need: > > procedure Set_Point(P: Union; R, Theta: Float) is > begin P := (R * sin (Theta), R * cos (Theta)); end Set_Point; > > (Of course, in an actual implementation I would have different derived > types for X and Y, R, and Theta, and Theta would probably be a > fixed-point type. But let's ignore that for now.) > > This is why the new interfaces in Ada will allow direct derivation from > one type, and adding in as many interfaces as you wish. Or, if you > prefer, no direct derivation and lots of interfaces. But you can only > directly derive from one parent type, because that is the way the world > works, not due to any limitations we are building into Ada. > > Notice that in my example, which was why I chose it, that the actual > implementation of the two potential parent types may match. But the > MEANINGS of the data fields are different. I think it is a good example that interfaces should be purely functional: interface Cartesian is set X,Y: property Float; end set; interface Polar is set R, Theta: property Float; end set; Alas, without object.method notation this impossible. http://www174.pair.com/yamir/programming/interfaces.htm Amir Yantimirov