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.1 required=5.0 tests=BAYES_20,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!DDN-WMS.ARPA!thoyt From: thoyt@DDN-WMS.ARPA (Thomas Hoyt) Newsgroups: comp.lang.ada Subject: Variable length strings... Message-ID: <8905302008.AA07776@ajpo.sei.cmu.edu> Date: 30 May 89 15:39:18 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: In issue #142, D. Papay is right on the $$$ with his comments on variable length strings. However... >...I suggest you remove the default expression " := 0" from your > record type ... and always declare ... with explicit discriminant > contraints... If you do this, you lose all the advantages of a parameterized record, i.e. variable length strings. Why not constrain the subtype of the range of the record parameter: ^^^^^ subtype Len_range is integer range 0..256; -- or some other max -- string length This way the compiler would know exactly how big the strings could ever get and plan accordingly...i.e. stop complaining. Of course, you could still have pretty huge strings without coming close to whatever Integer'Last is. Another advantage is that the writer of the generic could explicitly control how big the variable length strings could ever get, without having to rely upon implimentation details. You also eliminate a generic parameter, relieving the user of an unnecessary detail. Most text editing functions wouldn't ever need more than about 1024 chars at a time (need...hope?:-)) ****** Thomas Hoyt | "Government Computers for Government business..." CRC Systems, Inc. | "NO FUN ALLOWED..." thoyt@ddn-wms.arpa | "Oh no...it's written in COBOL..." ******