stung@iuvax.cs.indiana.edu (Sho-Huan Simon Tung) (02/03/90)
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
huss@nada.kth.se (H}kan Huss) (02/09/90)
rather easy. Some systems also provide interfaces to the toolkit layers of X. In our opinion, however, the main question is not the feasibility, but rather the desirability of this approach. We believe that the C interface is not suited for direct use from Scheme. To support this notion we have designed an interface between Scheme and X called SCIX, written entirely in Scheme. What we wanted to achieve with this system was a model of the X window system that more closely matched the means of abstraction available in Scheme. I.e, a model that is object-oriented from the bottom and up. We have found that this approach makes widget construction simple and elegant. The price of elegance is, as always, performance. Run interactively the system is rather inefficient. Thus, in order for it to be interesting one needs a compiling Scheme system. Our implementation is based on the WRL Scheme->C system. SCIX has been developed for Digital Equipment, but it is meant to be made freely available. It is scheduled to be released in March. Regards, Hakan Huss Johan Ihren <huss@nada.kth.se> <johani@nada.kth.se>
huss@nada.kth.se (H}kan Huss) (02/09/90)
Sorry, the first line of the previous post got mangled. It should have read: To interface Scheme to Xlib is, as several people have reported, rather easy...
mayer@hplabsz.HPL.HP.COM (Niels Mayer) (02/09/90)
In article <2891@draken.nada.kth.se> huss@nada.kth.se (H}kan Huss) writes: >rather easy. Some systems also provide interfaces to the toolkit >layers of X. In our opinion, however, the main question is not >the feasibility, but rather the desirability of this approach. We >believe that the C interface is not suited for direct use from Scheme. I agree that the xlib layer is too low-level for lisp programming ... that's why I like my UI components implemented in C. I've found WINTERP to be plenty fast -- As long as I'm not forcing XLISP to perform lots of grinding and garbage generating operations. THose should be written in C. I may prototype low level routines in XLISP, but the ones that matter end up in C. IMHO, hybrid programming is the way to go. So H}kan, are saying that the compiling scheme system is fast enough? I guess I need to read Bartlett's paper... ------------------------------------------------------------------------------- Niels Mayer -- hplabs!mayer -- mayer@hplabs.hp.com Human-Computer Interaction Department Hewlett-Packard Laboratories Palo Alto, CA. *
johani@nada.kth.se (Johan Ihren) (02/14/90)
We apologize for not replying earlier. We are in the middle of a period of exams right now... In article <4803@hplabsz.HPL.HP.COM>, mayer@hplabsz.HPL.HP.COM (Niels Mayer) writes: > > should be written in C. I may prototype low level routines in XLISP, > but the ones that matter end up in C. IMHO, hybrid programming is the > way to go. Of course it has to be hybrid programming, as Scheme does not have any primitives for interprocess communication ;-) The question is on which level the conversion between C and Scheme structures should occur, provided that one wants to be able to manipulate the data as standard Scheme objects. In our system it is done at a very low level. This enables us to have an environment much more suited for Scheme. We are not saying that our approach is the right one, but rather that there is use for both the WINTERP and the SCIX solutions to the problem. > So H}kan, are saying that the compiling scheme system is fast enough? > I guess I need to read Bartlett's paper... Yes, it is fast enough to be useful. The speed of SCIX is roughly equivalent to that of CLX (a well known binding to Common Lisp). We haven't done any formal benchmarks, this is based on elementary comparision of a few example applications. The main difference between CLX and SCIX is that CLX is an imperative interface on which object oriented layers (CLUE) can be/has been added. SCIX is thoroughly object oriented from the inside and out. A SCIX application runs between four and six times slower than the C equivalent. This can be disastrous for an application that mostly consists of a speedy user interface, but is not unusable in other situations. We also have ideas that will hopefully speed up the eventhandling considerably in the future ;-) The big problem with the C binding to X is that C isn't really suited to the task of modelling a window system. The result is a very large system that is used in different ways on different levels (Xlib vs the toolkit layer). This makes it cumbersome to write X code in C. Much of the elegance of the underlying X protocol has been lost among the deficiencies of a particular language. When using a more powerful language, like Scheme, it was interesting to try to redo it all, with the X protocol as a starting point. The result is much cleaner and much easier to understand as the SCIX environment is consistent on all levels. Yes, SCIX is definitely slower than an application written entirely in C, but if speed is crucial then maybe the entire application should be written in C. For applications that need to be written in Scheme, however, I think that the power of the SCIX model of X can outweigh the speed gains that would come from using the C bindings from within Scheme. Yes, we do widgets in Scheme as well. They are typically quite easy to write. A set of buttons (generic-, text- and pixmap-buttons) that we wrote currently consists of 70, 35 and 20 lines of Scheme code each. The latter two inherit the former... -- Johan Ihren Dept. of Computer Science, Royal Institute of Technology, Stockholm, Sweden Email: johani@nada.kth.se -or- <backbone>!sunic!nada!johani