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,f039470e8f537101 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-29 14:39:54 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: jimmaureenrogers@worldnet.att.net (Jim Rogers) Newsgroups: comp.lang.ada Subject: Re: Non-philosophical definition of Eiffel? Date: 29 Jul 2003 14:39:53 -0700 Organization: http://groups.google.com/ Message-ID: <82347202.0307291339.1f8a6b65@posting.google.com> References: <7u9Ua.13412$634.10307@nwrdny03.gnilink.net> <1059416297.548253@master.nyc.kbcfp.com> <1059486223.780998@master.nyc.kbcfp.com> <8tucivgbh5hkuicrpdeuavau8muf6a9mrh@4ax.com> <1059496557.747795@master.nyc.kbcfp.com> NNTP-Posting-Host: 209.194.156.4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1059514794 1778 127.0.0.1 (29 Jul 2003 21:39:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 29 Jul 2003 21:39:54 GMT Xref: archiver1.google.com comp.lang.ada:40969 Date: 2003-07-29T21:39:54+00:00 List-Id: Hyman Rosen wrote in message news:<1059496557.747795@master.nyc.kbcfp.com>... > Dmitry A. Kazakov wrote: > > There is little sense in contravariant arguments > > OK, I just want to make sure that we're talking about > the same thing, so let me give specific examples. I'll > write in C++ terms, just because. > > struct B1 { }; > struct D1 : B1 { }; > > struct B2 > { > virtual B1 &f1(); > virtual B1 &f2(); > virtual void f3(B1 &); > virtual void f4(D1 &); > virtual void f5(B1 &); > }; > > struct D2 : B2 > { > B1 &f1(); > D1 &f2(); > void f3(B1 &); > void f4(B1 &); > void f5(D1 &); > }; > > D2 d2; > B2 *b2 = &d2; > > f1) This is ordinary overriding, with same return type. > Pretty much legal in every language. > f2) This is covariant return type. Legal in C++. This > preserves LSP, since a call b2->f2() must return a > B1 &, and a D1 & is a B1 &. The equivalent in Ada would require that f2 return a class wide access type. In one case it would be an access to b2'class, in the other case it would be to d2'class. In general, neither C++ nor Java consider the function return type as part of the signature of a function. This means that a function in C++ or Java cannot be overriden with only a change in the return type. Compare this with Ada: package foo type foo_array is array(1..10) of float; function total(Item : foo_array) return float; function total(Item : foo_array) return integer; end foo; Ada allows the overloading of the "total" function based upon the return type of the function. Jim Rogers