UI event datatypes Lassi Kortela 06 Aug 2020 16:08 UTC

> The thing that concerns me about a plist representation is that it has
> to be constructed on the fly, whereas my design, though limited, can be
> as simple as a wrapped vector that gets mutated (not constructed) by the
> event-poll procedure, and so can be reused the next time.  My intuition
> is that performance matters here, though I know very well the dangers of
> premature optimization.

With terminals the cost of a list is definitely not a problem. Not sure
about cutting-edge GUIs (which are probably some VR headset stuff -- and
Scheme should get ready for VR).

BTW can't you reuse the existing cons structure of a list just as well
as a vector's?

> But if folks think this doesn't matter, then I can reformulate in terms
> of "Here are some well-defined types of events" rather than "An event
> can only be one of these".

I guess it could be:

(let loop ((e (make-null-event)))
   (read-event! e)
   (cond ((key-press-event? e)
          ...)
         ((mouse-button-event? e)
          ...))
   (loop e))

But I've tried to design an all-encompassing UI event datatype several
times and failed every time. So I would make it specific to each UI library.