comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: wait does not perform as expected
Date: Thu, 23 Feb 2023 19:35:46 +0200	[thread overview]
Message-ID: <k5pmfiFqm4vU1@mid.individual.net> (raw)
In-Reply-To: <75c3990e-eaab-47eb-bdba-3827b9fd4751n@googlegroups.com>

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

  parent reply	other threads:[~2023-02-23 17:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22 16:34 wait does not perform as expected Daniel Gaudry
2023-02-22 17:36 ` Niklas Holsti
2023-02-23 14:26   ` AdaMagica
2023-02-23 14:32     ` AdaMagica
2023-02-23 14:33     ` Daniel Gaudry
2023-02-23 14:39       ` AdaMagica
2023-02-23 17:15       ` Niklas Holsti
2023-02-23 17:35     ` Niklas Holsti [this message]
2023-02-23 17:49       ` Niklas Holsti
2023-02-23 18:14       ` Dmitry A. Kazakov
2023-02-23 18:29         ` Niklas Holsti
2023-02-23 18:47           ` Daniel Gaudry
2023-02-23 19:08             ` Niklas Holsti
2023-02-23 19:31             ` Niklas Holsti
2023-02-23 20:41           ` Dmitry A. Kazakov
2023-02-24 15:10             ` AdaMagica
2023-02-24 18:23               ` Niklas Holsti
2023-02-24 21:16 ` Jeffrey R.Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox