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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,197f249b225fabe2 X-Google-Attributes: gid103376,public From: "Norman H. Cohen" Subject: Re: Ada 83 versions of Ada 95 packages Date: 1996/12/24 Message-ID: <32C058C6.50F3@watson.ibm.com>#1/1 X-Deja-AN: 205840282 references: <19961224202100.PAA15408@ladder01.news.aol.com> content-type: text/plain; charset=us-ascii organization: IBM Thomas J. Watson Research Center mime-version: 1.0 reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada x-mailer: Mozilla 3.0 (Win95; I) Date: 1996-12-24T00:00:00+00:00 List-Id: johnherro@aol.com wrote: > I agree that the name of my package may be confusing, because what I > really wrote was a *substitute* for unbounded strings for use with an Ada > 83 compiler. I still hope that the package will prove useful to others. But a discriminant named Length with no default value suggests that every object of the type will be constrained to a particular length. Thus there is no way to implement procedures such as Append, Replace_Slice, and Delete that modify their Unbounded_String parameters. That is what Robert Dewar meant when he said that this looked like a fixed-length-string type. The natural way to implement Unbounded_String in Ada 83 is with an access-to-String type (adding an explicit Free operation as Robert suggested). The natural way to implement a Bounded_String type in Ada 83 is with a record consisting of a fixed-length string (whose length is the maximum length for the type) and a current-length component; Bounded_String should be limited so that its "=" can be overridden to ignore string components that are present in the record but not logically part of the value. This means you will have to provide a Copy operation to replace assignment, but that's desirable anyway to avoid unneeded copying. ("=" can be overridden for limited or nonlimited types in Ada 95, but only for limited types in Ada 83.) -- Norman H. Cohen mailto:ncohen@watson.ibm.com http://www.research.ibm.com/people/n/ncohen