comp.lang.ada
 help / color / mirror / Atom feed
From: AdaMagica <christ-usch.grein@t-online.de>
Subject: Re: wait does not perform as expected
Date: Fri, 24 Feb 2023 07:10:13 -0800 (PST)	[thread overview]
Message-ID: <79efa06f-180f-4b94-ae83-c0b818248340n@googlegroups.com> (raw)
In-Reply-To: <tt8j18$1u7lt$2@dont-email.me>

Dmitry A. Kazakov schrieb am Donnerstag, 23. Februar 2023 um 21:41:16 UTC+1:
> It is to expect it to work with the "standard" terminal [emulator]. 
> Anything else is a long shot.

Right, there may be weird file kinds where Get_Immediate fails.

Niklas Holsti schrieb am Donnerstag, 23. Februar 2023 um 19:29:36 UTC+1:
> On my system, if Look_Ahead uses getc and ungetc, it seems Get_Immediate 
> does not use the same buffers, and has no effect on those buffers. That 
> could be desirable behaviour in some cases, undesirable in others. 
> 
> On AdaMagica's system, it seems that Get_Immediate uses the same buffers 
> as Look_Ahead (getc/ungetc).

I further experimented.

  loop
    Get_Immediate (Char, Avl);  Put ("Get_Immediate: '" & Char & "', Available   => " & Avl'Image);  New_Line;
    delay 1.0;
  end loop;

Run in GPS, it behaves strangely (seems to be one of Dmitry's weird files)

ab c<return>
Get_Immediate: 'a', Available   => TRUE
Get_Immediate: 'b', Available   => TRUE
Get_Immediate: ' ', Available   => TRUE
Get_Immediate: 'c', Available   => TRUE
Get_Immediate: '
', Available   => TRUE                      long pause until:
<return>
Get_Immediate: '
', Available   => TRUE

It only reacts after <return> is pressed.

On a terminal window, the same executable reacts as I expect (this is why the delay statement is there).

Get_Immediate: ' ', Available   => FALSE
Get_Immediate: ' ', Available   => FALSE
Get_Immediate: ' ', Available   => FALSE       as long as no <return> is pressed
a                                                                         note: no <return>
Get_Immediate: 'a', Available   => TRUE
Get_Immediate: ' ', Available   => FALSE       and so on.

So bevore discussing how Get_Immediate is implemented on different hardware or different implementations, please read the RM paras I referenced and discuss them. Looks to me like the behaviour shown last is the correct one (let aside weird terminals).

Niklas, your GNAT is two years older than mine. I guess GNAT has been corrected (at least changed) in between.

If we all disagree how it should work, we should post this on Ada Comment.

  reply	other threads:[~2023-02-24 15:10 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
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 [this message]
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