Data Structures

Xlib has three basic kinds of data structures: documented C structures, undocumented C structures, and XIDs. The documented C structures are used as any C structure would be; the undocumented C structures are accessed through standard macros and functions; and the XIDs are used only as arguments to Xlib functions.

ProXL doesn't have these types, instead it has only foreign terms and regular Prolog terms. Foreign terms are Prolog terms that represent X objects. These objects are analogous to undocumented C structures in that their contents are not directly accessible, but it is not necessary to send a message to the server to get the contents.

Foreign terms, at the moment, are simply unary Prolog terms whose functor indicates the type of the foreign term and whose argument specifies the location of the contents of the data structure. Note that this implementation may be changed at any time, so you should not count on it.

One useful property of the current implementation is that the printed representation of a foreign term may be read back in, and will yield the same data structure. This is useful when debugging and when prototyping, since it means you can grab results of a goal you just ran and feed them in as arguments to the next goal you want to run.

All foreign terms representing XIDs contain not only the XID of the X resource, but also the display, and, where appropriate, the screen, on which this XID lives. This means that where Xlib requires both a display and an XID, ProXL only needs the foreign term. Therefore, very few ProXL procedures take a display as argument.