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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: 'Image (was: What exactly is the licensing situation with GNAT?) Date: Wed, 19 Nov 2014 13:46:41 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <54609F34.4080201@spam.spam> <35f01472-3510-4f67-8765-006fa8591c35@googlegroups.com> <9tc8w.73007$ZT5.37595@fx07.iad> <22a3816a-4e89-48f0-a126-dce581781beb@googlegroups.com> <084b1934-9641-425e-85ec-293e0334413e@googlegroups.com> <86bf69c8-eb08-4696-b6c9-3784f5c42213@googlegroups.com> <87389olqie.fsf@ixod.org> <19fa65d4-72c9-44ab-b44b-4ea0929c18f2@googlegroups.com> <87a93s8j4m.fsf@mid.deneb.enyo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 19 Nov 2014 13:46:41 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="da745e888d4a5182b5fda6212bbb0a63"; logging-data="15378"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Zahg5KwWLVQSl+6EQY1C1AHp1uuQbCdA=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:5/rsFNUnass0Z5j+bicCleyGcHg= Xref: news.eternal-september.org comp.lang.ada:23550 Date: 2014-11-19T13:46:41+00:00 List-Id: On Sat, 15 Nov 2014 20:58:39 +0100, Georg Bauhaus wrote: > On 15.11.14 18:32, Florian Weimer wrote: >> * Randy Brukardt: >> >>> Semi-related to this is that we approved Obj'Image as a >>> language-defined attribute, >> Did they drop leading space characters while they were at it? :-) > > Of course not, they know about the possibility of a '-', and how are you > going to write orderly column layout if in Ada there is no space! > > Perfect ground for debate. > > Will 'Image be user definable? Like Python's __str__? Very good for > obfuscation, then. Will the encoding be part of the definition, > so that I can use it in our existing trace logs? Something similar just came up in a VHDL context, where the question was asked, is '&' overloadable for non-string-or-character types. And it appears it is, so that you can simplify the creation of complicated strings (and eliminate leading spaces if you wish) by a package of functions overloading '&' to wrap 'Image for integer and similar types. The testcase (minimally translated) seems to work in Ada too (Gnat 4.9.1 at least), extension from single characters to 'image and strings should be obvious. -------------------------------------------------------- with Ada.Text_IO; procedure foo is function "&" (l: string; r: natural) return string is begin return l & character'VAL(r); end "&"; a: constant string := "abcd"; b: constant string := "efgh"; begin Ada.Text_IO.put_line( "concatenated string is " & a & -- Line 18 character'VAL(16#42#) & b & " " & a & 16#42# & b ); end foo; -------------------------------------------------------- -- Brian