caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Andrej Bauer <Andrej.Bauer@andrej.com>
To: caml-list@inria.fr
Subject: What the Graphics module is missing
Date: Wed, 26 Jan 2005 10:17:55 +0100	[thread overview]
Message-ID: <41F76043.9070600@andrej.com> (raw)

I recently wrote a simple single-window application in ocaml.
For artistic purposes I wanted it to give it a "raw" look (think VT100),
so I did want to use an existing library. The Graphics module seemed
like a good solution. However, I think the Graphics module is
missing a function that empties the event queue.

Suppose my program is doing something and while it is doing it, it
periodically polls for user interface events (think "cooperative
multitasking" from 1980's). In particular, I polled for mouse down and
mouse up events.

Later on, when the program is not doing anything, it makes sense to have
it wait for an event (rather than burn CPU by busy-waiting and polling).
BUT, since there is no way to empty the event queue, as far as I can
tell, the events that were polled during the first part will still be
sitting in the queue. The program will react to them, again, and the
effect is that some things may happen twice instead of once, which of
course is annoying. (Note that keypresses _can_ be emptied from the
queue because there is the Graphics.keypressed function, but really one
should be able to empty the whole queue.)

If the above description is confusing, imagine the following scenario:
in certain cases you want to empty the event queue in order to prevent
the user from doing a dangerous thing. For example, if you are going to
ask him "are you sure you want to format the hard disk?" then you better
empty the queue, lest the user pressed 'y' before he saw the question.

This would all be very easily solved if the ocaml people added an
"empty_queue" function to the Graphics module. I looked at the source
code and it seems it would be easy to do. Pretty please.

Or am I missing something obvious?

Andrej Bauer


                 reply	other threads:[~2005-01-26  9:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41F76043.9070600@andrej.com \
    --to=andrej.bauer@andrej.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).