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-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: wait does not perform as expected Date: Thu, 23 Feb 2023 19:35:46 +0200 Organization: Tidorum Ltd Message-ID: References: <75c3990e-eaab-47eb-bdba-3827b9fd4751n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net znZGIsPHxzIl7hA+WTp94wyiz87UwwOpa8MNB/nKwNQpQiY/co Cancel-Lock: sha1:u/lNqlSzE6LPOEUfRD/sruXgcRs= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US In-Reply-To: <75c3990e-eaab-47eb-bdba-3827b9fd4751n@googlegroups.com> Xref: reader01.eternal-september.org comp.lang.ada:64970 List-Id: On 2023-02-23 16:26, AdaMagica wrote: > Niklas Holsti schrieb am Mittwoch, 22. Februar 2023 um 18:36:06 UTC+1: >> On my system, Get_Immediate does /not/ use the inputs collected (but not >> "consumed") by Look_Ahead, but instead checks if there are _new_ input >> keystrokes. If there are none, Get_Immediate returns "not Available" >> (Hit is False) and so the loop continues. > > Are you sure? That is what I observe. > With GNAT Community 2021 (20210519-103) targeting x86_64-w64-mingw32, > > loop > Look_Ahead (Char, EoL); Put ("Look_Ahead: '" & Char & "', End_of_Line => " & EoL'Image); New_Line; > Get_Immediate (Char, Avl); Put ("Get_Immediate: '" & Char & "', Available => " & Avl'Image); New_Line; > end loop; > > I get: > > ab x > Look_Ahead: 'a', End_of_Line => FALSE > Get_Immediate: 'a', Available => TRUE > Look_Ahead: 'b', End_of_Line => FALSE > Get_Immediate: 'b', Available => TRUE > Look_Ahead: ' ', End_of_Line => FALSE > Get_Immediate: ' ', Available => TRUE > Look_Ahead: 'x', End_of_Line => FALSE > Get_Immediate: 'x', Available => TRUE > Look_Ahead: '0', End_of_Line => TRUE > Get_Immediate: ' <- This is the EoL > ', Available => TRUE > On my system: ab x Look_Ahead: 'a', End_of_Line => FALSE Get_Immediate: '', Available => FALSE Look_Ahead: 'a', End_of_Line => FALSE Get_Immediate: '', Available => FALSE Look_Ahead: 'a', End_of_Line => FALSE Get_Immediate: '', Available => FALSE and so on for ever, with Look_Ahead never waiting for new input. The behaviour on my system is certainly different from yours. I can see that both behaviours could be useful, depending on the program's needs. However, I was certainly surprised to see my system's behaviour, and a priori I expected to get the behaviour you see. My system is oldish: GNAT Community 2019 (20190517-83) macOS 10.14.6 Mojave This difference appears when mixing Look_Ahead and Get_Immediate, which seems to make no sense for the original question, and which I advised the OP not to do. Using just Get_Immediate should give the OP what they want.