From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-91-241.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.0 required=3.0 tests=none autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Weird behavior of Get character with trailing new lines. Date: Sat, 23 Sep 2023 11:25:05 +0200 Organization: A noiseless patient Spider Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 23 Sep 2023 09:25:04 -0000 (UTC) Injection-Info: dont-email.me; posting-host="2bb8be0c39d57643ddd8a84a07cf5fc3"; logging-data="789057"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/oQzQW+5k39nGbrzppiNe1K2nFdnr5tWU=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:1eHYsC9ICW+PavnyMEoThIYrLN8= Content-Language: en-US In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:65700 List-Id: On 2023-09-23 10:39, Niklas Holsti wrote: > On 2023-09-23 10:02, J-P. Rosen wrote: >> That's why I never check End_Of_File, but handle the End_Error >> exception. It always works. > > True, but it may not be convenient for the overall logic of the program > that reads the file. That program often wants do to something with the > contents, after reading the whole file, and having to enter that part of > the program through an exception does complicate the code a little. It rather simplifies the code. You exit the loop and do whatever is necessary there. Testing for the file end is unreliable and non-portable. Many types of files simply do not support that test. In other cases the test is not file immutable with the side effects that can change the program logic. It is well advised to never ever use it. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de