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: border1.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada 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 Organization: Also freenews.netfront.net; news.tornevall.net Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 16 Aug 2013 03:17:48 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="da68e1c0dc00d4aa5d0283c494e3a17a"; logging-data="14534"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xqpFW1TdipW0xyS/OApz7B0szsHXSlY4=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: Cancel-Lock: sha1:29D4DH77cTqbssjyVQ3zSWVC1Dk= X-Original-Bytes: 2406 Xref: number.nntp.dca.giganews.com comp.lang.ada:183050 Date: 2013-08-15T20:17:46-07:00 List-Id: 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