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,start X-Google-Attributes: gid103376,public From: Dale Stanbrough Subject: Design of Ada.Strings.Bounded Date: 1997/07/11 Message-ID: <5q4mel$16r$1@goanna.cs.rmit.edu.au>#1/1 X-Deja-AN: 256187785 Distribution: world X-XXMessage-ID: Organization: Royal Melbourne Institute of Technology Newsgroups: comp.lang.ada Date: 1997-07-11T00:00:00+00:00 List-Id: 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. This is exactly the same problem that we had in Pascal, that unconstrained types in Ada solved. One possible design that would have solved this problem is to have Ada.Strings.Bounded declare and abstract tagged type, with all of the subprograms declared abstract, and a small generic package with the type inside. e.g. package Ada.String.Bounded is type Bounded_String is abstract tagged private; function Length (Item : Bounded_String) return Natural is abstract; function Max_Length (Item : Bounded_String).... is abstract; ... generic Max : Positive; package Generic_Bounded_Length is ... type Bounded is new Bounded_String with private; ... end Generic_Bounded_Length; end Ada.Strings.Bounded; This would at least allow class wide programming for functions such as Check_Spelling above. Dale