Nп/п : 42 из 100
 От   : Niklas Holsti                       2:5075/128        23 сен 23 17:03:14
 К    : Dmitry A. Kazakov                                     23 сен 23 17:06:02
 Тема : Re: Weird behavior of Get character with trailing new lines.
----------------------------------------------------------------------------------
                                                                                 
@MSGID: <kn89h2F64t4U1@mid.individual.net>
3a3ca148
@REPLY: 1@dont-email.me> 4ffd803c
@REPLYADDR Niklas Holsti
<niklas.holsti@tidorum.invalid>
@REPLYTO 2:5075/128 Niklas Holsti
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID:
<kn89h2F64t4U1@mid.individual.net>
@RFC-References: 1@dont-email.me>
1@dont-email.me> 1@dont-email.me> <kn7mhtF58psU1@mid.individual.net>
1@dont-email.me>
@TZUTC: 0300
@PID: Mozilla/5.0 (Macintosh; Intel Mac OS X
10.14; rv:102.0) Gecko/20100101 Thunderbird/102.12.0
@TID: FIDOGATE-5.12-ge4e8b94
On 2023-09-23 12:25, Dmitry A. Kazakov wrote:
> 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. 


Oh?


> You exit the loop and do whatever is necessary there.

That is exactly what happens in the "while not End_Of_File" loop.

If you want to use End_Error instead, you have to add an exception 
handler, and if you want to stay in the subprogram`s statement sequence 
without entering the subprogram-level exception handlers, you have to 
add a block to contain the reading loop and make the exception handler 
local to that block.

To me that looks like adding code -> more complex. Of course not much 
more complex, but a little, as I said.


> 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.

I suppose you are talking about the need for End_Of_File to possibly 
read ahead past a line terminator? If not, please clarify.

That said, I certainly think that a program reading files should be 
prepared to handle End_Error, especially if a file is read at several 
places in the program (and not in a single loop as in the present program).

 --- Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:102.0)
Gecko/20100101 Thunderbird/102.12.0
 * Origin: Tidorum Ltd (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх