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!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!storethat.news.telefonica.de!telefonica.de!news-fra1.dfn.de!newsfeed.ision.net!newsfeed2.easynews.net!ision!newsfeed.arcor.de!newsspool4.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: <1179953657.839272.160320@a26g2000pre.googlegroups.com> <1179991769.376381.252010@m36g2000hse.googlegroups.com> <12h6mi42jcha0.7f9vfsnihjwr$.dlg@40tude.net> <1180011507.159515.46920@o5g2000hsb.googlegroups.com> <1180079541.558215.256570@h2g2000hsg.googlegroups.com> <1180124867.710641.176330@k79g2000hse.googlegroups.com> <1k165n4jwxna3$.1mpx49xvcrc0z$.dlg@40tude.net> <1180254636.632499.3340@o5g2000hsb.googlegroups.com> <1p717twnydnre$.1j6izygvqo832.dlg@40tude.net> <1180425803.422075.100090@o5g2000hsb.googlegroups.com> <1180452858.118039.67740@w5g2000hsg.googlegroups.com> <1180510814.812025.251580@u30g2000hsc.googlegroups.com> Date: Wed, 30 May 2007 10:43:47 +0200 Message-ID: NNTP-Posting-Date: 30 May 2007 10:41:31 CEST NNTP-Posting-Host: 36331691.newsspool2.arcor-online.net X-Trace: DXC=POgV\RJ^IObfF8a^:6>b7eA9EHlD;3Ycb4Fo<]lROoRa8kFo_ga9DkTEIma X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:15976 Date: 2007-05-30T10:41:31+02:00 List-Id: On 30 May 2007 00:40:14 -0700, Maciej Sobczak wrote: > On 29 Maj, 19:07, "Dmitry A. Kazakov" > wrote: > >>> We are talking about real: >> >>> X := Y; >> >> Huh, how are going to design a non-referential container of T'Class? > > I don't. :-) > Polymorphism and references come hand in hand if you need the ability > to reassign. Copy-initialization is the only place where you can > safely get away with "values" of T'Class. Are you going to sell me pointers, right here, in c.l.a? (:-)) Referential semantics is an implementation detail. You propose to expose it to defend a fiction. But it would be in vain, because assigning class-wide references in this context is semantically equivalent to assigning the targets. > I think that the mess has its source in the push to have T'Class > behaving like normal value. This is all meta-programming is about: dealing with polymorphic values = programming in terms of sets of types. >>> I say that you need one type String, that possibly uses strategy >>> internally to delegate details like encoding. You don't need encoding >>> to "leak out" at the level of types that the final user operates on. >> >> That would be indeed a mess. How would you pass an UTF-8 string to GTK+ >> which knows nothing about your fancy patterns? > > Then it should know. It cannot, it is ANSI C. > Otherwise there is no way it can interpret > correctly what I pass as parameters, unless you want to have > "implicit" conversions for parameters. To interpret, to convert etc, all this requires a distinct type. Which is why different representations have to be mapped to different types. >> Why don't you use the >> advantages of the types system? > > I do use it, I just don't elevate implementation details to the level > of type that is handled directly by the user. I don't see any handling required. But let it be, then how is it different from your void * approach? When you create a void * you have to somehow specify the hidden parameter of the case-statement: void * X = Create_UTF8 ("foo"); With types you just specify the type of the object instead: X : UTF8_String := "foo"; >>> You can (and should) have dispatching internally in the implementation >>> of operations of String. I'm not proposing any case statements here! >> >> Here you are. What is the difference between internally and externally >> dispatching assignments? > > Assignment is an operation that is meaningful syntactically - that's > why it is so tempting. Internally you can have anything else, > including regular subprogram calls that will do necessary conversions. But not assignments? The question is how do I do dispatching assignment? Your point was that I shall not do it publicly. But, may I dispatch privately? If yes then how? And where is any difference? If not, then the only way left is a case-statement. >> Static polymorphism does not allow mixing types. > > ? Instances from a statically polymorphic class of types are unrelated types. You cannot have any polymorphic object from that class, only specific objects. For the same reason you cannot have any class-wide operation from that class. >> Further you cannot design >> a library for formatting strings which would not be generic itself. > > 1. So? Write an editor for such strings, store a string, send it over the network, do anything after uninstalling the compiler ... > 2. Yes, I can. Just use arbitrary string type for formatting and then > convert to the destination type. Why should I bother to have UTF-8 or ASCII strings if anything is Wide_..._Wide_Unbounded anyway? What are you going to do if the endianess of Wide x n Character does not fit your machine? >> The former is quite possible and IMO is the only right way to go. Note that >> the language should also allow declaring symmetries of the methods to >> reduce the number of independent variants. > > Yes, but that reduces the complexity by a constant only, the problem > is still fundamentally squared. It is how it is. No matter how you would handle them, you have to all of them. Whatever pattern you use, you will have to deal with this number of cases. Do you seriously propose to define some of the cases improperly, just because there are too many of them? (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de