Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!stung From: stung@iuvax.cs.indiana.edu (Sho-Huan Simon Tung) Newsgroups: comp.lang.scheme Subject: Re: X bindings in Scheme? Message-ID: <34721@iuvax.cs.indiana.edu> Date: 2 Feb 90 16:09:31 GMT References: <9001311838.AA02827@jove.pa.dec.com> <6599@ubc-cs.UUCP> Reply-To: stung@iuvax.cs.indiana.edu (Sho-Huan Simon Tung) Organization: Indiana University, Bloomington Lines: 24 In article <6599@ubc-cs.UUCP> manis@cs.ubc.ca (Vincent Manis) writes: >Actually, what I'd like is Xt (or, even better, Motif) from Scheme. It >would be even better to be able to write widgets in Scheme! The problem >is that the architecture of Xt involves a lot of callbacks, and, >generally (unless you're using the DECWRL compiler) you can't call >Scheme from C. I have found a way to get around the problem. The trick is: - use a vector to store the Scheme callback functions and client_data. - use the index to the vector to communicate between Scheme and C. - use a "standard_callback" function (written in C). standard_callback's client data will always be the index to the vector. If this callback is called by Xt it simply set a few flags which indicates information about widget-id, client_data (the index), and call_data. - XtMainloop need to be written in Scheme which simply polls the flags while looping. (if callback occured, use the index to find the Schems callback function and call it with the desired data.) Simon Tung Department of Computer Science Indiana University