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,FREEMAIL_FROM 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-04 06:48:19 PST Path: archiver1.google.com!news2.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.mathworks.com!wn13feed!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc01.POSTED!not-for-mail Message-ID: <3F7ECF99.8090004@comcast.net> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Is the Writing on the Wall for Ada? References: <3F739C1D.4030907@attbi.com> <3F78E850.8010401@comcast.net> <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> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc01 1065275297 24.34.139.183 (Sat, 04 Oct 2003 13:48:17 GMT) NNTP-Posting-Date: Sat, 04 Oct 2003 13:48:17 GMT Organization: Comcast Online Date: Sat, 04 Oct 2003 13:48:17 GMT Xref: archiver1.google.com comp.lang.ada:220 Date: 2003-10-04T13:48:17+00:00 List-Id: 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. 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; 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. -- Robert I. Eachus "Quality is the Buddha. Quality is scientific reality. Quality is the goal of Art. It remains to work these concepts into a practical, down-to-earth context, and for this there is nothing more practical or down-to-earth than what I have been talking about all along...the repair of an old motorcycle." -- from Zen and the Art of Motorcycle Maintenance by Robert Pirsig