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=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4c86cf2332cbe682 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-12 10:16:07 PST Path: nntp.gmd.de!Germany.EU.net!howland.reston.ans.net!gatech!newsfeed.pitt.edu!uunet!newsgate.watson.ibm.com!watnews.watson.ibm.com!ncohen From: ncohen@watson.ibm.com (Norman H. Cohen) Newsgroups: comp.lang.ada Subject: Re: Ada.strings.bounded problems? Date: 12 Jan 1995 18:16:07 GMT Organization: IBM T.J. Watson Research Center Distribution: world Message-ID: <3f3rl7$kts@watnews1.watson.ibm.com> References: Reply-To: ncohen@watson.ibm.com NNTP-Posting-Host: rios8.watson.ibm.com Date: 1995-01-12T18:16:07+00:00 List-Id: In article , ka@socrates.hr.att.com (Kenneth Almquist) writes: |> Tarjei Jensen wrote: |> This is definitely a weakness of Ada. There is no way to implement a |> single bounded string type that can be constrained to implement various |> maximum string lengths. It would not be too hard to add a bounded |> arrays (a generalization of bounded string) to Ada, but I don't recommend |> it, given the current complexity of Ada. This is definitely a weakness of Jensen's understanding of Ada. There IS a way to implement bounded strings with the bound given as a constraint, so simple that it is found in many introductory examples: package Bounded_Strings is type Bounded_String (Max_Length: Positive) is private; ... -- all sorts of useful operations private type Bounded_String (Max_Length: Positive) is record Current_Length : Natural := 0; Text : String (1 .. Max_Length); end record; end Bounded_Strings; This approach is easily generalized to other kinds of arrays. -- Norman H. Cohen ncohen@watson.ibm.com