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,9fb64e4c58f1fe X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: overload ":=" ??? Date: 1996/07/24 Message-ID: #1/1 X-Deja-AN: 169930525 references: <4soh73$56h@newsbf02.news.aol.com> organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada Date: 1996-07-24T00:00:00+00:00 List-Id: In article tarjeij@ulrik.uio.no (Tarjei Jensen) writes: > The problem with bounded string is that it assigns a global > maximum string size instead of letting each string have its own > maximum size. The former is not particularly flexible while the > latter really require a user defined ":=". The generic package Ada.Strings.Bounded can be instantiated as often as you want. I have written program which had six instantiations... Well, not really. It had five instantiations which occured once per program invocation, and a sixth whose size was determined every time the enclosing procedure was called. > Not the least because the maximum length of the strings might be different. > e.g: > a : counted_string(4) := "1234"; > b : counted_string(5) := "1234"; -- four characters and space for five > a := b; -- Will not work with current version of Ada Try: ... package Counted is new Ada.Strings.Bounded.Generic_Bounded_Length(10); A : Counted.Bounded_String := To_Bounded_String("1234"); B : Counted.Bounded_String := To_Bounded_String("Some value"); ... A := B; --works fine. Of couse if instead you say: ... package Counted4 is new Ada.Strings.Bounded.Generic_Bounded_Length(4); package Counted5 is new Ada.Strings.Bounded.Generic_Bounded_Length(5); A : Counted4.Bounded_String := To_Bounded_String("1234"); B : Counted5.Bounded_String := To_Bounded_String("1234"); Now you have to write: ... A := Counted4.To_Bounded_String(Counted5.To_String(B)); Of course, if you want, you can make all this less verbose by using use clauses and perhaps even defining a conversion operation: function Convert(B: in Counted5.Bounded_String) return Counted4.Bounded_String is begin return Counted4.To_Bounded_String(Counted5.To_String(B)); end; pragma Inline(Convert); -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...