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,640b65cbfbab7216 X-Google-Attributes: gid103376,domainid0,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!newsfeed01.sul.t-online.de!t-online.de!newsfeed.velia.net!noris.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Ada.Strings.Bounded 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: <47F26C46.3010607@obry.net> <44d88b93-6a90-4c18-8785-2164934ba700@a9g2000prl.googlegroups.com> <47F652F7.9050502@obry.net> <47f7028d$1_6@news.bluewin.ch> <47F749CB.30806@obry.net> <480111a5$0$23695$9b4e6d93@newsspool2.arcor-online.net> <5d94b37c-20cd-46cf-b4c9-94bd2047c438@b5g2000pri.googlegroups.com> <0a2bbbb1-19d8-41d3-84a0-321cd045a48b@1g2000prf.googlegroups.com> Date: Mon, 14 Apr 2008 10:00:04 +0200 Message-ID: <1oezq4ijzah23.18y7fwriuqe6s.dlg@40tude.net> NNTP-Posting-Date: 14 Apr 2008 10:00:04 CEST NNTP-Posting-Host: c30aba60.newsspool4.arcor-online.net X-Trace: DXC=R:Lb?\_n;]?^cW`WBF>WQ<4IUK2Ik];WbK7h62[6LHn;2LCV>7enW;^6ZC`4IXm65S@:3>?MO]T^L8=7L9 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:20928 Date: 2008-04-14T10:00:04+02:00 List-Id: On Sun, 13 Apr 2008 16:52:00 -0700 (PDT), Eric Hughes wrote: > Speaking formally, which I was trying to do (but failing in the > details), almost-a-string is a subset of not-a-string. Axiom > satisfaction has sharp boundaries that don't usually coincide with > ordinary conceptual boundaries. Informally, sure, they're both > strings. But the Ada String type, with its padding, does not satisfy > the axioms of universal_string. The problem is that it's a fixed > array, not a fixed array allocation with a variable length like > Bounded_String. If I assign the value "A", a String of length 1, to a > String(2), the length of its value as a universal_string changes from > 1 to 2. So even simple assignment violates the axioms. If we had universal_string, it would have no assignment anyway, because all universal objects are immutable. There is a difference between types and their constrained subtypes in terms of substitutability. That's why the language has Constraint_Error defined. The contracts extended by Constraint_Error aren't violated and everything is fine. > The problem that was the nexus of the original discussion is that > string literals are of type String and not deemed elements of > universal_string. I don't see any harm here. You cannot assign literals. BTW, there are funny language rules which prevent things like this: type Integer is range -5..5; -- On some tiny machine L : constant := ("abcd" & "defg" & "defg")'Length / 3; -- Illegal anyway So you cannot exploit the limitation of the string index being Positive in order to construct strings longer than the index at compile time. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de