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,a5cdfaf37bba8923 X-Google-Attributes: gid103376,public From: kst@sd.aonix.com (Keith Thompson) Subject: Re: Design of Ada.Strings.Bounded Date: 1997/07/13 Message-ID: #1/1 X-Deja-AN: 256718131 Sender: news@thomsoft.com (USENET News Admin @flash) X-Nntp-Posting-Host: pulsar References: <5q4mel$16r$1@goanna.cs.rmit.edu.au> Organization: Aonix, San Diego, CA, USA Newsgroups: comp.lang.ada Originator: kst@pulsar Date: 1997-07-13T00:00:00+00:00 List-Id: In <5q4mel$16r$1@goanna.cs.rmit.edu.au> Dale Stanbrough writes: > After contemplating how i would use Ada.Strings.Bounded, i wondered about > the decisions that were made when it was designed. > > If I use it in a package, and want to add any additional features, or > use it as a parameter type > > e.g. > function Check_Spelling (Item : Bounded_80) return Boolean; > > then this is rather unfortunate when i want to check the spelling > of an item in a Bounded_81 string. Probably the easiest way to handle this is to declare Check_Spelling to take a parameter of type String. To pass it a parameter of type Bounded_80, just call To_String. I do wonder, though, why the maximum length of a Bounded_String was made a generic parameter rather than a discriminant. Thus, rather than ... package Ada.Strings.Bounded is ... generic Max : Positive; package Generic_Bounded_Length is type Bounded_String is private; ... end Generic_Bounded_Length; end Ada.Strings.Bounded; we could have ... package Ada.Strings.Bounded is ... type Bounded_String(Max_Length : Positive) is private; ... end Ada.Strings.Bounded; This would slightly complicate the function To_Bounded_String (it would need an extra parameter to specify the Max_Length of the result), but it would otherwise simplify the use of Bounded_Strings from the user's point of view. It would also allow operations between Bounded_Strings of different Max_Lengths. On the other hand, it might make operations on Bounded_Strings slightly less efficient, since they'd have to allow for the discriminant values. Was this approach considered? If so, why was it rejected? -- Keith Thompson (The_Other_Keith) kst@sd.aonix.com <*> TeleSo^H^H^H^H^H^H Alsy^H^H^H^H Thomson Softw^H^H^H^H^H^H^H^H^H^H^H^H^H Aonix 5040 Shoreham Place, San Diego, CA, USA, 92122-5989 "Zathras warn Zathras, but Zathras never listen to Zathras." -- Zathras