comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: What's the cause of extra new line with Text_IO when program exit
Date: Thu, 15 Aug 2013 20:17:46 -0700
Date: 2013-08-15T20:17:46-07:00	[thread overview]
Message-ID: <kuk5kq$e66$1@dont-email.me> (raw)
In-Reply-To: <kujtmh$doi$1@dont-email.me>

On 08/15/2013 06:02 PM, Zhu, Qun-Ying wrote:
>
> When executing, they have different behavior.
>
> For hello, you have:
> # ./hello
> Hello World!
> #
>
> While for hello_stream, you got:
> # ./hello_stream
> Hello World!#
>
> If change the last Put to Put_Line for hello, you got the same result.
> I would like to know why it is like that.

Ada.Text_IO writes to a text file of type Ada.Text_IO.File_Type; Hello writes to 
the file Standard_Output. Text files consist of lines of text; lines are 
conceptually terminated by a line terminator. For a version of Unix such as you 
seem to be using, the conceptual terminator is an actual LF character.

While it is not defined by the language what happens to a File_Type when the 
program ends [ARM A.7(6)], it does require that File_Type have finalization [ARM 
A.10.1(86)]. A logical thing for this finalization to do is to make sure that 
the last line is terminated, and it appears that your implementation does this.

A stream is a different creature than a text file, and doesn't know about lines 
or terminators, so it should not be surprising that it adds no terminator.

-- 
Jeff Carter
"It is the German who is so uncourteous to his verbs."
A Scandal in Bohemia
122


  reply	other threads:[~2013-08-16  3:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-16  1:02 What's the cause of extra new line with Text_IO when program exit Zhu, Qun-Ying
2013-08-16  3:17 ` Jeffrey Carter [this message]
2013-08-17 17:54   ` Dennis Lee Bieber
2013-08-17 21:54     ` Jeffrey Carter
2013-08-19 21:58     ` 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