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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2ff5c149712ec0eb X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Ada Interfaces and the Liskov Substitution Principle Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Thu, 24 May 2007 09:39:19 +0200 Message-ID: NNTP-Posting-Date: 24 May 2007 09:37:12 CEST NNTP-Posting-Host: 5506b7a6.newsspool3.arcor-online.net X-Trace: DXC=ZOHl3=G8]Q>L2C_`koXfC5McF=Q^Z^V384Fo<]lROoR1Fl8W>\BH3Y2I?:ad:b3M79DNcfSJ;bb[5FCTGGVUmh?4LK[5LiR>kg2IQY]_o=6>80 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:15899 Date: 2007-05-24T09:37:12+02:00 List-Id: On Wed, 23 May 2007 21:47:32 +0200, Stefan Lucks wrote: > to me, it seems as if Ada 2005 is bluntly violating the Liskov > Substitution Prinicple. Huh, as well as Ada 83 did. There is no need in much code, just write subtype Non_LSP_Subtype is String (1..80); or subtype Positive is Integer range 1..Integer'Last; or, for that matter "constant", "in", "out", "not null", etc. All these are examples of non-LSP subtypes. > My understanding of the Liskov substitution principle, see > http://en.wikipedia.org/wiki/Liskov_substitution_principle > is that as Partens.Parent implicitely (by not being limited) provides > certain primitve operations, such as ":=" and "=", and Stepchild.Object > takes away these primitive operations, It is illegal, but if it were legal, then yes, disallowing operations breaks LSP. However, see above, mere passing a variable as "in" does it as well in the sense that "in T" is not an LSP-subtype of T. > What do you guys think about this? LPS is totally irrelevant as long as substitutability violation can be detected at compile time. This is why "constant" does not worry anybody. A method disallowing is perfectly OK, if you cannot call it. LSP violation becomes a problem when substitutability is indeterminable until run-time. In may cases we still choose to live with that. Constrained Ada subtypes is an example of. Another is multi-methods Foo (X, Y : T), when called on different children of T. In such cases Ada adds Constraint_Error to the interface of each subprogram and things become "substitutable" again. LSP violation is catastrophic when undetected. I think that renaming array objects with changing bounds falls under this category. (Apart from "unchecked" stuff) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de