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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.50.29.9 with SMTP id f9mr3250603igh.0.1438264526257; Thu, 30 Jul 2015 06:55:26 -0700 (PDT) X-Received: by 10.140.97.199 with SMTP id m65mr138780qge.29.1438264526225; Thu, 30 Jul 2015 06:55:26 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.ripco.com!news.glorb.com!f3no4931125igg.0!news-out.google.com!b31ni1417qge.0!nntp.google.com!69no2815927qgl.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 30 Jul 2015 06:55:25 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=81.203.145.32; posting-account=AFCLjAoAAABJAOf_HjgEEEi3ty-lG5m2 NNTP-Posting-Host: 81.203.145.32 References: <2df4698f-4c8e-457c-822d-209cb2f8ab5e@googlegroups.com> <014427b1-ff7a-4a69-82e6-0330af77ed96@googlegroups.com> <1438244829.17005.26.camel@obry.net> <1438260153.17520.14.camel@obry.net> <3825fe2a-b768-4cd5-b3c3-3dc97ddd997a@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <625dfec1-0fff-4155-b6da-e298eadf8789@googlegroups.com> Subject: Re: Running a preprocessor from GPS? From: EGarrulo Injection-Date: Thu, 30 Jul 2015 13:55:26 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:27209 Date: 2015-07-30T06:55:25-07:00 List-Id: On Thursday, July 30, 2015 at 3:38:25 PM UTC+2, Dmitry A. Kazakov wrote: > On Thu, 30 Jul 2015 06:21:42 -0700 (PDT), EGarrulo wrote: >=20 > > On Thursday, July 30, 2015 at 2:42:36 PM UTC+2, Pascal Obry wrote: > >> Le jeudi 30 juillet 2015 =E0 04:54 -0700, EGarrulo a =E9crit : > >>> By the way, the implementation of GNAT.Formatted_String is cryptic. > >>> Isn't Ada code supposed to be readable?=20 > >>=20 > >>> I must be missing something. > >>=20 > >> Yes, sure: Open Mind score below 0! > >=20 > > Not really. Compare the arbitrary overloading of "+", "-" and > > "&" (and the cryptic "#") in GNAT.Formatted_String here: > >=20 > > procedure Fout is > > F : Formatted_String :=3D +"%c %% %#08x"; > > Vc : Character :=3D 'v'; > > Vi : Integer :=3D 12; > > begin > > F :=3D F & Vc & Vi; > > Put_Line (-F); -- Prints: "v % 0x00000c" > > end Fout; > >=20 > > with the explicit formatting directives here (I am not sure that > > this is valid Ada, but you should get the idea): > >=20 > > procedure Fout is > > F : Formatted_String; > > Vc : Character :=3D 'v'; > > Vi : Integer :=3D 12; > > begin > > F :=3D ("%A %% %A", (Format (Vc),=20 > > Format (Vi, > > Prefix =3D> "0x" = =20 > > Base =3D> 16, > > Width =3D> 8, > > Filler =3D> "0")); > > Put_Line (F); -- Prints: "v % 0x00000c" > > end Fout; > >=20 > > The only convention that you need to know is that "%A" inserts > > an argument and that "%%" inserts a literal "%". Much simpler, > > don't you think? And extensible! You can define "Format" > > for your own types, independently from "Formatted_String". >=20 > declare > Text : String (1..40); > Pointer : Integer :=3D Text'First; > begin > Put (Text, Pointer, Vc & " % 0x"); > Put (Text, Pointer, Vi, Base=3D>16,Fill=3D>'0',Field=3D>6,Justify=3D>R= ight); > Put_Line (Text, 1..Pointer - 1); Thank you. Hence the functionality is already there. You only need to wrap it in a more convenient interface.