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.134.202 with SMTP id pm10mr3093622igb.2.1438262502975; Thu, 30 Jul 2015 06:21:42 -0700 (PDT) X-Received: by 10.140.30.197 with SMTP id d63mr667001qgd.12.1438262502933; Thu, 30 Jul 2015 06:21:42 -0700 (PDT) Path: buffer2.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!pg9no5334102igb.0!news-out.google.com!b31ni1378qge.0!nntp.google.com!69no2808758qgl.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 30 Jul 2015 06:21:42 -0700 (PDT) In-Reply-To: <1438260153.17520.14.camel@obry.net> 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> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3825fe2a-b768-4cd5-b3c3-3dc97ddd997a@googlegroups.com> Subject: Re: Running a preprocessor from GPS? From: EGarrulo Injection-Date: Thu, 30 Jul 2015 13:21:42 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.giganews.com comp.lang.ada:194511 Date: 2015-07-30T06:21:42-07:00 List-Id: 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! Not really. Compare the arbitrary overloading of "+", "-" and "&" (and the cryptic "#") in GNAT.Formatted_String here: 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; with the explicit formatting directives here (I am not sure that this is valid Ada, but you should get the idea): 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; 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".