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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM 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!postnews.google.com!k79g2000hse.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Ada Interfaces and the Liskov Substitution Principle Date: 31 May 2007 06:46:51 -0700 Organization: http://groups.google.com Message-ID: <1180619211.595952.116690@k79g2000hse.googlegroups.com> References: <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> <1180529642.741098.224230@q66g2000hsg.googlegroups.com> <1ljmbgesxien.syhurcvjdcd2$.dlg@40tude.net> <1180558336.041236.211560@p77g2000hsh.googlegroups.com> <1j91i6rk18kqd.4zjp36eyvps3.dlg@40tude.net> NNTP-Posting-Host: 137.138.37.241 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1180619212 3322 127.0.0.1 (31 May 2007 13:46:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 31 May 2007 13:46:52 +0000 (UTC) In-Reply-To: <1j91i6rk18kqd.4zjp36eyvps3.dlg@40tude.net> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.10) Gecko/20070228 Red Hat/1.5.0.10-0.1.slc3 Firefox/1.5.0.10,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: k79g2000hse.googlegroups.com; posting-host=137.138.37.241; posting-account=Ch8E9Q0AAAA7lJxCsphg7hBNIsMsP4AE Xref: g2news1.google.com comp.lang.ada:15991 Date: 2007-05-31T06:46:51-07:00 List-Id: On 31 Maj, 10:15, "Dmitry A. Kazakov" wrote: > You cannot make a class of non-limited types limited. Why not? Let's just say so or write it in RM. > It would be > inconsistent. Protected objects are limited even if they contain only Integers. The inconsistencies are there anyway, so why fighting for unrealistic purity? > A specific object is just a constrained instance of a > class-wide object. Nothing prevents it from having additional operations (in the specific view, not class-wide). > This is the model of what is going on. Whether the > objects from the class should or not have assignment or any other operation > depends solely on the problem domain. It is the programmer's choice. Exactly, but the language "helps" the programmer to make some choices. In Ada most of the time the justification for these is "it's safer". In my opinion it is safer to not have assignments in class-wide types and I have nothing against the language to remind me. > >>> Even with strings, you might want to share the strategy for character > >>> encoding. > > >> I don't. String has a value, only this counts. > > > According to the above distinction, string is a value type. > > As well as the polymorphic string from the class of: > > (UTF-8, "abc") := (ASCII, "def"); -- Why is it a problem? It assumes too much. To do this operation you need to dispatch to some encoding or converting strategy anyway - but then, why elevate it so high? Keep it internally: declare X, Y : String; -- one String type is enough begin X.setEncoding(ASCII); X := "def"; Y.setEncoding(UTF8); Y := X; end; The above of course cannot work with the current semantics of assignment in Ada. This is unfortunately broken. > > Internal strategy can be a class. That's a good place for dispatch > > (note: I use the term "strategy" from the OO design pattern with the > > same name). > > This is what I meant. Let's move to the internals. How the internal class > can be assigned? Can it? You don't need to assign it. It is enough if you can replace it. Yes, referential semantics is useful sometimes. -- Maciej Sobczak http://www.msobczak.com/