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!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!newsfeed.arcor.de!newsspool1.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 15:56:45 +0200 Message-ID: <7b9qiwewqptb$.16g096so0lqf8.dlg@40tude.net> NNTP-Posting-Date: 24 May 2007 15:54:38 CEST NNTP-Posting-Host: a90b0785.newsspool3.arcor-online.net X-Trace: DXC=1BaR`:V^9oYaoembcbF;DQMcF=Q^Z^V3X4Fo<]lROoRQFl8W>\BH3YRJbPh_bC`T9TDNcfSJ;bb[UFCTGGVUmh?TLK[5LiR>kgRS5C5`7L0PO_ X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:15909 Date: 2007-05-24T15:54:38+02:00 List-Id: On Thu, 24 May 2007 13:12:56 +0200, Stefan Lucks wrote: > Dmitry A. Kazakov wrote: > >> [...] mere passing a variable as "in" does it as >> well in the sense that "in T" is not an LSP-subtype of T. > > You are using a very broad and generalised interpretation of the LSP. My > interpretation -- and I believe this is the common and usual one -- is > that "X: in T" in the parameterlist of a subprogram does not deal with > some "artificial" type "in T", just with "T". If it dealt with T, then the following program were legal: procedure Foo (X : in out T); procedure Bar (X : in T) is begin Foo (X): -- Fortunately illegal in Ada end Bar; > The "in" is part of the > subprogram's contract, not a part of X's contract. So there is no conflict > with LSP. But: 1. either the subprogram is a primitive operation then its contract is a part of the type contract => subject of LSP. 2. or it is not, and then substitutability does not apply (the type does not change) => absolutely substitutable anyway. > Perhaps you should follow the crowd and > narrow your interpretation as well? Yes, but then LSP should be re-formulated appropriately. And there is nothing automatically wrong in disallowing operations. I would like to see it in Ada. >> 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. > > Yes, that is an ugly patch. But it appears tricky to come up with a better > solution ... Yes, this is a problem. In particular, when some property (like Constraint_Error propagation because of substitutability violation) becomes determinable in some, but all context. The language designer has no choice to make it illegal. The best thing he can do is to spill a warning. This is a way too little. There should be a way to have a finer grained classification of substitutability contexts than everywhere vs nowhere, such that the programmer could help the compiler by specifying the contexts where indeterminable substitutability were an error. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de