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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-06 05:04:54 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Is the Writing on the Wall for Ada? Date: Mon, 06 Oct 2003 14:14:09 +0200 Message-ID: <8qm2ov43djse19is7pk79jf5p7ifvvuff2@4ax.com> References: <3F797748.3000203@noplace.com> <834clb.uan1.ln@skymaster> <3F79EF18.7060600@comcast.net> <3F7B1076.8060106@comcast.net> <5mknnv4u96qqudrt4bd8n4t1cljp2fjlp8@4ax.com> <3F7C810E.7070100@comcast.net> <3F7E25C1.1060509@comcast.net> <3F7ECF99.8090004@comcast.net> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1065441892 16208413 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:301 Date: 2003-10-06T14:14:09+02:00 List-Id: On Sat, 04 Oct 2003 13:48:17 GMT, "Robert I. Eachus" wrote: >Dmitry A. Kazakov wrote: > >> No. I am complaining that the universal concept of using the discriminant >> values as the constraints is not applicable to all types. This irregularity >> causes abberations all over the language design. >> >> For instance, you have used it to justify a generics-based design for >> bounded strings as opposed to a much more clearer and easier to use >> solution based on discriminated records. > >No, the Bounded_String package just uses generics to set the maximum >length. You can write a non-generic version of the package if you want. And why the standard goes other way? (:-)) > The only 'trick' involved is that you need two record types, and the >discriminant--and the bounds--of the innner type must not depend on the >outer type. > >subtype Bound is Integer range 1..30; >type Inner(Length: Bound := 0) is record > S: String(1..Length); >end record; >type Bounded is record C: Contents := Inner; end record; > >type Ragged_Array is array(Integer range <>) of Bounded; What if 31 character length string is required? Now we have answered the question, why Bounded_String was made generic - to avoid arbitrary limitations like the number 30 in the example. BTW I commented this solution in my other post. It is not a solution, of course. >That is all of Ada.Strings.Bounded that you really need. The rest of >the declarations are for convenience: > >function To_String(B: in Bounded) is begin return B.C.S; end To_String; >pragma Inline(To_String); > >As you can see, all of the operations for type Bounded end up being very >efficient, and are really only there as 'syntactic sugar' to make it >easier for users to used the package. I guess that is why I am >"frothing at the mouth" in this discussion of how difficult it is to use >Ada.Strings.Bounded instead of Strings. I personally don't like the >'extra' generic nesting in Ada.Strings.Bounded, but in general when I >use the package, it is wrapped in another generic that does other things >with the type, like mapping it to database entries, so I only pay the >generic instantiation overhead in my programming once. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de