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,FREEMAIL_FROM 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 09:36:23 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!logbridge.uoregon.edu!feed2.news.rcn.net!rcn!nntp.abs.net!ash.uu.net!spool.news.uu.net!not-for-mail Date: Tue, 29 Jul 2003 12:35:57 -0400 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030611 Thunderbird/0.1a X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Non-philosophical definition of Eiffel? References: <7u9Ua.13412$634.10307@nwrdny03.gnilink.net> <3F215120.1040706@attbi.com> <1059151910.357790@master.nyc.kbcfp.com> <1059416297.548253@master.nyc.kbcfp.com> <1059486223.780998@master.nyc.kbcfp.com> <8tucivgbh5hkuicrpdeuavau8muf6a9mrh@4ax.com> In-Reply-To: <8tucivgbh5hkuicrpdeuavau8muf6a9mrh@4ax.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1059496557.747795@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1059496557 25998 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:40955 Date: 2003-07-29T12:35:57-04:00 List-Id: 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 &. f3) Again, ordinary overriding, with the same argument types in base and derived. Legal everywhere. f4) Contravariant argument types. This also preserves LSP, but I don't know of a language which implements it. LSP is preserved because a call of b2->f4() can only pass a D1 & argument, and a D1 & is a B1 &. f5) Covariant argument types. This is Eiffel's model. LSP is not preserved, because a call to b2->f5() may pass any B1 &, while d2.f5() wants only a D1 &.