From: NiGHTS <nights@unku.us>
Subject: Re: Assembling Complex Strings Containing Carriage Returns Prior to Using Ada.Text_IO.Put?
Date: Wed, 22 Oct 2014 10:39:02 -0700 (PDT)
Date: 2014-10-22T10:39:02-07:00 [thread overview]
Message-ID: <87dab7c9-95d8-4354-a4c2-53971c2167cb@googlegroups.com> (raw)
In-Reply-To: <m27ikc$98j$1@dont-email.me>
On Wednesday, October 22, 2014 2:25:25 AM UTC-4, Jeffrey Carter wrote:
> On 10/21/2014 10:57 PM, NiGHTS wrote:
>
> >
>
> > Complex_String : Ada.Strings.Unbounded.Unbounded_String;
>
> > EOL : String := ASCII.CR'Img;
>
>
>
> I presume you're using GNAT; this gives you the image of the enumeration value
>
> CR; I suspect you want the enumeration value (character) itself. Try using
>
>
>
> EOL : constant Character := Ada.Characters.Latin_1.CR;
>
>
>
> 'Img is a non-standard, vendor-dependent attribute; you should not use it in
>
> production code if you have any interest in portability. ASCII is an obsolete
>
> unit and should not be used.
>
>
>
> What system uses CR for line terminators these days? I suspect the result will
>
> not be what you expect, which is why a better approach would be to actually
>
> convert this to Ada and simply use a series of Put_Line statements, rather than
>
> trying to copy the mistakes of C in Ada.
>
>
>
> > The searches I performed on Google seem to be void of any hints on how to get this working. I can't imagine that I am the only one with this requirement in Ada.
>
>
>
> That's because this is not the Ada Way.
>
>
>
> --
>
> Jeff Carter
>
> "We call your door-opening request a silly thing."
>
> Monty Python & the Holy Grail
>
> 17
Do keep in mind that the strategy of buffering output before sending it to screen is not "old", its "smart". I did consider what you suggested for this particular project, but then I realized that rewriting the code in question to use Put_Line would actually make the code both less readable and far less efficient, both things which are not the Ada way.
While using Put_Line is safer in its portability, its avoidance in this particular instance is comparable to favoring "goto" for a specific section of code after determining the alternative as being more complex or otherwise less desirable.
Thank you for your response.
next prev parent reply other threads:[~2014-10-22 17:39 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-22 5:57 Assembling Complex Strings Containing Carriage Returns Prior to Using Ada.Text_IO.Put? NiGHTS
2014-10-22 6:20 ` mockturtle
2014-10-22 6:28 ` Ludovic Brenta
2014-10-22 8:12 ` mockturtle
2014-10-22 14:36 ` Maciej Sobczak
2014-10-22 14:55 ` Dmitry A. Kazakov
2014-10-24 1:35 ` Keith Thompson
2014-10-22 16:01 ` Shark8
2014-10-22 16:50 ` Jeffrey Carter
2014-10-22 18:59 ` Simon Wright
2014-10-22 23:45 ` Dennis Lee Bieber
2014-10-23 11:38 ` G.B.
2014-10-23 16:22 ` Shark8
2014-10-22 17:32 ` Adam Beneschan
2014-10-22 17:55 ` NiGHTS
2014-10-22 17:16 ` NiGHTS
2014-10-22 6:25 ` Jeffrey Carter
2014-10-22 17:39 ` NiGHTS [this message]
2014-10-22 11:16 ` Björn Lundin
2014-10-22 17:44 ` Adam Beneschan
2014-10-22 17:47 ` Adam Beneschan
2014-10-22 18:01 ` NiGHTS
2014-10-22 22:34 ` Shark8
2014-10-22 23:32 ` Adam Beneschan
2014-10-24 2:45 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox