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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: Pascal Obry Newsgroups: comp.lang.ada Subject: Re: Your wish list for Ada 202X Date: Sun, 30 Mar 2014 21:59:26 +0200 Organization: Home - http://www.obry.net Message-ID: <1396209566.14855.1.camel@pascal.home.net> References: <7f1c01c5-3563-4b94-9831-152dbbf2ecdc@googlegroups.com> <1396206120.12713.8.camel@pascal.home.net> <1rmd466o46wkh$.xv2pypcsl4nb.dlg@40tude.net> Reply-To: pascal@obry.net NNTP-Posting-Host: L9vAWPXftET0fEf5/kGUFw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Complaints-To: abuse@aioe.org X-Mailer: Evolution 3.8.5-2+b3 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:19057 Date: 2014-03-30T21:59:26+02:00 List-Id: Le dimanche 30 mars 2014 =C3=A0 21:33 +0200, Dmitry A. Kazakov a =C3=A9crit= :=20 I did such things, it is not so simple. >=20 Sure! You need a set of "seed" functions to produce initial Formatted_String, > e.g. >=20 > function "&" (L, R : Character) return Formatted_String; > function "&" (L : Character; R : Integer) return Formatted_String; > ... >=20 No since you always start with the Formatted_String (not derived from string). We need at least a function to create the formatted_string from a string: function "+" (Format : in String) return Formatted_String; Then: +"%c" & var Or you have to use Empty_Formatted_String constant in each expression. >=20 > Another consideration is efficiency, as it would keep on copying the string > upon each concatenation. >=20 Copies should be avoided by using a reference semantic. Note that I have declared Formatted_String as: type Formatted_String is private; Maybe it should be a tagged type. This type is a record with the format. The result (Unbounded_String?) and an index to the current format. That's what I'm thinking. Let's say we have: type Formatted_String is record Format : Unbounded_String; Index : Positive; Result : Unbounded_String; end record; Then +"%c %c" Set such record to ("%c %c", 1, "") Then with : & Var If Var is not a character =3D> raise exception Let's say Var :=3D 'x' If a char then the record becomes : ("%c %c", 3, "x") That's how I would do such implementation. --=20 Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://v2p.fr.eu.org http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B