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!p77g2000hsh.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Ada Interfaces and the Liskov Substitution Principle Date: 30 May 2007 13:52:16 -0700 Organization: http://groups.google.com Message-ID: <1180558336.041236.211560@p77g2000hsh.googlegroups.com> References: <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> <1180529642.741098.224230@q66g2000hsg.googlegroups.com> <1ljmbgesxien.syhurcvjdcd2$.dlg@40tude.net> NNTP-Posting-Host: 85.3.234.226 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1180558336 31817 127.0.0.1 (30 May 2007 20:52:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 30 May 2007 20:52:16 +0000 (UTC) In-Reply-To: <1ljmbgesxien.syhurcvjdcd2$.dlg@40tude.net> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: p77g2000hsh.googlegroups.com; posting-host=85.3.234.226; posting-account=Ch8E9Q0AAAA7lJxCsphg7hBNIsMsP4AE Xref: g2news1.google.com comp.lang.ada:15982 Date: 2007-05-30T13:52:16-07:00 List-Id: On 30 Maj, 15:56, "Dmitry A. Kazakov" wrote: > >> Referential semantics is an implementation detail. > > > No, it is not. It gives you explicitly the possibility to "reseat" the > > referer as well as sharing semantics. These are not details. > > No shared semantics in this context. The values identify themselves, > otherwise the type shall be limited and no assignment would come in > question. When I think about it, it seems to me that you have just pinned down the very essence of this problem. There is no need to artificially banning assignments for class-wide types. Just force them all to be limited. Problem solved. I'm not joking. There is a distinction between value types and object types. These names might not be meaningful within the Ada terminology, but the border line is basically between types which instances represent themselves and those which instances represent external concepts or entities (but not necessarily). The latter often form hierarchies. When I said that I've never seen reasonable assignment with a hierarchy, it expressed exactly this distinction. Assignment is for values, not for objects. And guess what? You often need generics (templates, etc.) for value types. Don't get rid of them yet. ;-) > > 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. > You claim that these values > *semantically* cannot be assigned. No. String can (and should) have assignment. But its internal strategy for character encoding might not. It might be replaceable (yes, we have references!), but the strategy object itself is not necessarily assignable - and shouldn't be if it's class- wide. > Why should I *statically* know string bounds and encoding? Any reason? You might simply want to. For example, to separate domains. But you don't need to know and then you can have replaceable strategies within a single string type. > > Just a reminder - we are talking about: > > > X := Y; > > Remember, you have just allowed this, both are void *. It is you who has introduced void* into this discussion. I have no idea why. > >> Your point was that I shall not do it publicly. But, may I dispatch > >> privately? > > > Privately you can dispatch to your internal strategies to get > > character conversions, buffers, etc. > > How? To dispatch you need a class, which you have just scraped. 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). > >> Write an editor for such strings, store a string, send it over the network, > >> do anything after uninstalling the compiler ... > > > Still don't see the problem. > > How to instantiate a template when the type is unknown? You don't. What was the problem? > >> What are you going to do if the endianess > >> of Wide x n Character does not fit your machine? > > > And why should I bother with endianness here? > > Because of the number of possible permutations of the bytes in Wide x n > Character. I presume that Character, Wide x n Character are pointers to ... > mmm, don't know what. Anyway, have fun! I still have no idea why you have introduced endianness into this discussion. What does it have to do with assigning class-wide types? The concept of endianness is meaningful only for data marshalling (when the data is in transit, not when it's stored), which is outside of string itself. Again - "strategy" is the keyword here. > >> Whatever pattern you use, you will have to deal with this number of > >> cases. > > > Or I just delegate to locale and conversion library that is part of my > > operating system. > > And to whom delegates the conversion library? (:-)) Why should I bother? Does it bother you that the mechanics of writing to NFS file are different from writing to FIFO pipe? Same Ada code can do both. We have operating systems to provide services, right? (Unless we write operating systems, that is. :-) ) > > On my system I can have LOTS of different locales: > > > $ locale -a | wc -l > > 502 > > > Do you really expect me to have 502 classes in my program just for > > strings? > > Yes, if you wanted to prevent locales from mixing, if you wanted to deal > with text orientation in different languages, if you wanted > locale-dependent sorting etc. There must be a deep elaborated hierarchy I > suppose. Good luck, then. :-) -- Maciej Sobczak http://www.msobczak.com/