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,103b407e8b68350b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-30 08:32:10 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Anybody in US using ADA ? One silly idea.. Date: Thu, 30 Jan 2003 17:32:09 +0100 Message-ID: <25ji3v8n915cnnnaqpjvm4f7i01a66r9pf@4ax.com> References: <7iLY9.2401$qb1.464@nwrddc01.gnilink.net> <1043680098.61106@master.nyc.kbcfp.com> <3afc3v4uur2kvd53v4ul18b5npjfm188o3@4ax.com> <1043773909.385612@master.nyc.kbcfp.com> <1043855067.848326@master.nyc.kbcfp.com> <3OXZ9.85359$Ve4.6306@sccrnsc03> <1043880843.44251@master.nyc.kbcfp.com> <1043938782.244443@master.nyc.kbcfp.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 1043944329 34954586 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:33601 Date: 2003-01-30T17:32:09+01:00 List-Id: On Thu, 30 Jan 2003 09:59:42 -0500, Hyman Rosen wrote: >Dmitry A. Kazakov wrote: >> Now, consider that this additional code not just shifts >> a reference, but creates a new object (Ellipse). > >I suppose a language could define this copy-in/copy-out >stuff with conversions. I don't know how useful it would >be, but I guess I could be convinced with a compelling >example. Consider Unbounded_String, Bounded_String, String. Why one cannot be a subtype of another? In my view it is very reasonable, because all of them are in fact just different representation of the same concept of "array of characters". And a representation has to be no issue. >I would point out that this is completely >orthogonal to OO. No, it is an extension of OO and ADT. It is a simple consequence of the principle that interface and implementation have to be separated. >That is, the only relationship that >needs to exist between the two types is for them to be >interconvertible. This what you require by saying: class Circle : public Ellipse. namely that Circle is convertible to Ellipse and back. The conversions might be empty, but it is more general approach to think that they are always present. >That you want this implies that you >are a secret C++ programmer :-) C++ defines some conversion of this type, but it does not allow me to define my own type relations. The former is bad because, I do not want these conversions. The latter is just OO. >> subtype Non_Negative is Float range 0.0..Float'Last; >> >> Would you reimplement "-" for Non_Negative just because Non_Negative >> is not "isa" Float? > >I'm a little puzzled. I would try to arrange for "-" NN -> NN >to be undefined, and for "-" NN -> Float to have its obvious >meaning. I don't know what Ada allows in this case, but that's >what I want. Well, but "-" has covariant result, so either you immediately violate LSP with the consequence that NN will be unusable, or like Ada does, define "-": NN x NN -> NN in a most reasonable way. >> Surely not, you would just catch Constraint_Error as necessary. > >Surely not, why would I want exceptions raised at run-time for >errors that should be prevented at compile-time? Because, you cannot detect all substitutability violations at compile-time. You might well define "-" contravariant, but this medicine is even worse than the illnes. >> Absolutely. LSP cannot be enforced in all contexts. > >I don't think you grasped my meaning. I mean that LSP should be >decided based on the implemented properties of the programmed >objects, not on the abstract or real-world objects that they >(partially) model. You can group your properties into subsets, >which become interfaces, and then code which operates on these >objects can choose to receive the smallest set of interfaces >that it needs. I think this is why the C++ template model is so >appealing. C++ template functions *automatically* require only >the properties they actually use, so you don't need to do an >a priori factorization of properties into subsets. I know you >object to the fact that the set of used properties is specified >only implicitly, and is therefore subject to accidental change, >but the positive side is there as well. This could be an option if the software were never modified. In the real world you would like to have as much compile-time checks as possible, even for errors which will never occur in the given version of the program. You never know in which direction the code will evolve. And there is no better mechanism for compile-time checks than the type system. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de