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: a07f3367d7,2e6723b897ab47fb X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.216.113.70 with SMTP id z48mr684386weg.6.1344851032574; Mon, 13 Aug 2012 02:43:52 -0700 (PDT) Path: n2ni107269548win.0!nntp.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!news-feed.eu.lambdanet.net!news.bcc.de!newsfeeder.ewetel.de!newsfeed.kamp.net!newsfeed.kamp.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada.Locales pseudo-string types Date: Wed, 8 Aug 2012 12:11:14 +0200 Organization: cbb software GmbH Message-ID: References: <78707b6e-88a3-453a-a37c-840f7a62e703@googlegroups.com> <7303f906-0f6a-4d97-ae15-36b4056ede6c@googlegroups.com> <257b4f44-b6c6-4c79-8c6e-dec947a3ce25@googlegroups.com> <19aidilocj3ue$.ljphjv09js71.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-08-08T12:11:14+02:00 List-Id: On Wed, 8 Aug 2012 02:32:53 -0700 (PDT), Marius Amado-Alves wrote: > I agree that letting contracts contain dynamics stuff brings us dangerously close to weak typing. > > But let me recall that the original case is all static: we want to convert from > > type Language_Code is array (1 .. 3) of Character range 'a' .. 'z'; > > to > > type String is array(Positive range <>) of Character > with Pack; > > Nothing could go wrong in this case. That depends on the way you define wrongness. To me it is already wrong because types are different. Note that from my POV being structurally equivalent means nothing. Type is a set of values and operations. What operations are defined on Language_Code? Are they same to ones of String? If so, then conversion is possible. But I don't know it. It is not the language business to determine. Moreover, for non-tagged types it is broken anyway, because any user-defined operations are not primitive and get ignored by the compiler where you expected that least. There really should be no types without classes and primitive operations. If I ran the circus I would allow means to make Language_Code a proper subtype of String while retaining necessary constraints. Furthermore, regarding the points J-P. made, it is important to have subtypes differently implemented. That would leave the issues of optimization to the programmer's discretion. You would define a conversion from Language_Code to String and use the former with any operations taking in-String. You would declare a backward conversion and would use it with all out-String operations. Two conversions more and you would be able to use String with Language_Code operations. > Or in the general case of converting from subranges to fullranges, no > matter how deep in the type structure. If the structure is the same, and > the operand has a subrange (or a match) in the same place as the target, > then please (dear Ada 202X) convert it. This is what I certainly disagree with. Structure is an implementation detail. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de