From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: wait does not perform as expected
Date: Thu, 23 Feb 2023 19:49:04 +0200 [thread overview]
Message-ID: <k5pn8gFqm4tU2@mid.individual.net> (raw)
In-Reply-To: <k5pmfiFqm4vU1@mid.individual.net>
On 2023-02-23 19:35, Niklas Holsti wrote:
> 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,
Or (on my system) when mixing ordinary Get and Get_Immediate. If I
replace the Look_Ahead call with just a test for End_Of_Line and then
Get (Char), I get a similar effect, showing that on my system
Get_Immediate ignores any previously buffered, unconsumed input line,
whether it results from Look_Ahead or from Get:
ab x
Get : 'a', End_of_Line => FALSE
Get_Immediate: '', Available => FALSE
Get : 'b', End_of_Line => FALSE
Get_Immediate: '', Available => FALSE
Get : ' ', End_of_Line => FALSE
Get_Immediate: '', Available => FALSE
Get : 'x', End_of_Line => FALSE
Get_Immediate: '', Available => FALSE
Get : '', End_of_Line => TRUE
Get_Immediate: '', Available => FALSE
and then the Get call waits for new input (a new input line).
next prev parent reply other threads:[~2023-02-23 17:49 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
2023-02-23 17:49 ` Niklas Holsti [this message]
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