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,640b65cbfbab7216 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!1g2000prf.googlegroups.com!not-for-mail From: Eric Hughes Newsgroups: comp.lang.ada Subject: Re: Ada.Strings.Bounded Date: Sun, 13 Apr 2008 16:52:00 -0700 (PDT) Organization: http://groups.google.com Message-ID: <0a2bbbb1-19d8-41d3-84a0-321cd045a48b@1g2000prf.googlegroups.com> 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> NNTP-Posting-Host: 166.70.57.218 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1208130721 14130 127.0.0.1 (13 Apr 2008 23:52:01 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 13 Apr 2008 23:52:01 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 1g2000prf.googlegroups.com; posting-host=166.70.57.218; posting-account=5RIiTwoAAACt_Eu87gmPAJMoMTeMz-rn User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20927 Date: 2008-04-13T16:52:00-07:00 List-Id: On Apr 13, 2:10 pm, Robert A Duff wrote: > There is no such thing as Ada.Strings.String. I thought maybe you meant > the package Ada.Strings.Fixed, but that package has no type. It uses > the predefined type String (which is declared in Standard, and > therefore visible everywhere), and it _does_ have concatenation ops. > So I don't understand what you mean. I meant .Fixed and I meant the regular String type. And I forgot that concatenation isn't declared. Blah. Sorry for generating confusion. For my own part, I only use String for string literals. > I agree that blank-padding is a nearly useless thing to do. > But you can do a lot with fixed-length strings, so long > as you program them in a mostly-functional style. I'm not denying any of that. My critique is pretty much solely about names. > String and Unbounded_String are both strings of characters, > so I don't see why it's "plain wrong". [...] > Adding some (near-useless) operations on String that do blank-padding > doesn't suddenly make String not a string type. No, but it does create a violation of axioms that define universal_string. Such axioms are essentially those of a semigroup with the trivial inverse operation where only the empty string has an inverse. (Perhaps we might also say "maximally non-invertible semigroup". ) You start adding padding manipulations in there and these axioms are no longer true. 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. I'm not denying that having an informally-a-string type which is a fixed-length array is useful and efficient. It's just not a possible implementation of universal_string. And it's not like you can't interconvert, but you should probably not do so silently, because you're not satisfying a set of common axioms. 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. There's a second problem, one of usability, that the default string type ought to be Unbounded_String, because it's closest to universal_string and would create the fewest surprises (manifested in exceptions raised). That's really another discussion, though. Eric