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: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Your wish list for Ada 202X Date: Sun, 30 Mar 2014 21:33:21 +0200 Organization: cbb software GmbH Message-ID: <1rmd466o46wkh$.xv2pypcsl4nb.dlg@40tude.net> References: <7f1c01c5-3563-4b94-9831-152dbbf2ecdc@googlegroups.com> <1396206120.12713.8.camel@pascal.home.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: KX5nm0jf7du4gHjHR6mb/g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:19056 Date: 2014-03-30T21:33:21+02:00 List-Id: On Sun, 30 Mar 2014 21:02:00 +0200, Pascal Obry wrote: > Le dimanche 30 mars 2014 à 05:28 -0700, francois_fabien@hotmail.com a > écrit : >> One wish to ease Input/output : >> To have some equivalent of C primitive : printf("%c %c %c %c %c \n %c %c %c %c %c \n", > > Well, this is possible in Ada with some coding of a package, one could > write something like (maybe already implemented by someone, I remember a > simple_io package or something like that): > > Formatted_Print > ("%c %c %c %c %c \n %c %c %c %c %c \n" > & Var1 & Var2 & Var3 & Var4 & Var5 & Var6 & Var7 & Var8); > > You just have to code the Formatted_Print routine once for all. No big > deal: > > type Formatted_String is private; > > Format_Error : exception; > > function "&" > (F : Formatted_String; V : Character) return Formatted_String; > function "&" > (F : Formatted_String; V : Integer) return Formatted_String; > function "&" > (F : Formatted_String; V : Float) return Formatted_String; > ... > > procedure Formatted_Print (F : Formatted_String); > > procedure Formatted_Print > (File : Text_IO.File_Type; > F : Formatted_String); I did such things, it is not so simple. You need a set of "seed" functions to produce initial Formatted_String, e.g. function "&" (L, R : Character) return Formatted_String; function "&" (L : Character; R : Integer) return Formatted_String; ... Or you have to use Empty_Formatted_String constant in each expression. Another consideration is efficiency, as it would keep on copying the string upon each concatenation. One method to deal with that is to use reference counting in Formatted_String. When the argument F has the reference count 1 it is updated in place and the result is returned. Otherwise F is cloned, the copy is updated and then returned. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de