User event data fields
It would be great if sdl2:user-event's data1 and data2 fields could be used for a useful purpose, such as to hold Scheme objects. This will be a bit tricky and we might have to place restrictions on what kinds of objects can be stored there, but I think it can be done.
The lolevel unit has procedures that would be important to this. For example, object->pointer
and pointer->object
. However, that has the problem that the object may be moved in memory during GC, so the pointer might not stay valid.
It is possible to "evict" an object using object-evict
, which copies the object into static memory so the pointer address will not change. However, this is not ideal because the entire object is recursively copied and thus will no longer refer to the original objects, but it might be suitable for simple objects like symbols, strings, and numbers. If we can't find a better solution, then as a last resort, users could put their real data in a global data structure, then store the key or index of the data in the user event's data slot, so they can retrieve the real data later.
Another hopeful possibility is locatives. Locatives can be used as pointers, and can refer to many kinds of objects (including vectors, so we could stuff other kinds of objects in a temporary vector). However, the documentation does not say whether locatives might move during GC. If they do not move, then this could be the key to storing arbitrary objects in a user event.
Do some research and ask CHICKEN experts. Find out what the best solution would be, then implement it.