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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f868292008c639ce X-Google-Attributes: gid103376,public From: Charles Hixson Subject: Re: C vs. Ada - strings Date: 2000/05/03 Message-ID: <39105211.4808CA35@earthlink.net>#1/1 X-Deja-AN: 618748351 Content-Transfer-Encoding: 7bit References: <390F0D93.F835FAD9@ftw.rsc.raytheon.com> <8eons4$sqj4@ftp.kvaerner.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 957370904 198.94.156.19 (Wed, 03 May 2000 09:21:44 PDT) Organization: EarthLink Inc. -- http://www.EarthLink.net MIME-Version: 1.0 NNTP-Posting-Date: Wed, 03 May 2000 09:21:44 PDT Newsgroups: comp.lang.ada Date: 2000-05-03T00:00:00+00:00 List-Id: "Tarjei T. Jensen" wrote: > ... > > Whether strings suck is a matter of how easy it is to work with them, not the > number of fancy operations you can perform on them. ... True within limits. Range slices are very nice. But so would be dynamic resizing! And the ability to compare different varieties. It seems to me, that in the context of Ada it would make sense to have two kinds of string defined initially: Type 1, fixed would be a range of characters (<> for the range). This would be able to compare all subtypes. Of course, it wouldn't allow resizing. Type 2, Unbounded strings. This would allow dynamic resizing, assignment, and comparisons and assignment from the first type. All other (system library defined) strings would be defined as subtypes of these two. I suppose that one could argue that there should be another two of type wide_character...But I really want there to be only two types of string, so instead I would want to go back and redefine the base type of the character that the string was built on to be the ancestor of Character and Wide_Character. A problem exists here, in that Character uses half the storage space of Wide_Character. I don't think that subtyping would be a good way to proceed, but I don't want to loose the type conformance. It's reasonably easy to define comparison mappings between Character and Wide_Character, and even assignment mappings aren't impossible, though one does end up with a many-to-one mapping. But the word length requirements just don't mesh. Now it's pretty obvious how one could define the strings if one didn't worry about the character width issue, but how should they be defined to allow for this? (Just in case: No, I'm not enrolled in a class. This is not an assignment. I'm just trying to figure out how to design things in Ada [which, to me, equates to Ada95].)