[gambit-list] dwm
Eduardo Cavazos
wayo.cavazos at gmail.com
Thu Feb 26 23:07:57 EST 2009
lowly coder wrote:
>> so my current dev environment is xmonad + emacs + gambit; this is about to
>> become xmonad + jedi + gambit; but I'd prefer to have my window manager be
>> running on gambit too
>>
>> so ... is there anyone else out there also interested in this? we can
>> probably start out with something like scwm or sawmill and hack it to run on
>> gambit ... or if you're really good with x11, we can even start with some
>> thing leaner
Eduardo Cavazos wrote:
> DWM consists of a single C file. Check out the size:
>
> /tmp/dwm-5.4.1 # wc -l dwm.c
> 1729 dwm.c
>
> So here's another approach. Port that to Chicken/xlib (I think it's the
> easiest off the shelf library). It's less than 2000 lines... If there
> are no unforseen hicups, this is a weekend project.
Er... I don't wanna mislead anyone so let me clarify.
I took a closer look at the code in 'dwm.c'. A straight port using
R5RS+xlib would probably take longer than a weekend. :-)
In order to do it in a weekend (Hmmm.... call it wm48? :-)) you'd need
some facilities in Scheme (perhaps some macros, an object system, or
both) to conveniently express alot of the terse idioms of C. The 'dwm'
author is a great hacker and gets alot done in very little space. So a
naive port to Scheme would cause an explosion in lines.
With the right abstractions there might be a reduction in lines.
One area which makes a naive conversion to Scheme non-trivial (or at
least very verbose) is X structs. Consider this function from 'dwm.c':
----------------------------------------------------------------------
void
configurenotify(XEvent *e) {
XConfigureEvent *ev = &e->xconfigure;
if(ev->window == root && (ev->width != sw || ev->height != sh)) {
sw = ev->width;
sh = ev->height;
updategeom();
updatebar();
arrange();
}
}
----------------------------------------------------------------------
Assigning 'sw' in many Scheme xlib bindings (including Gambit's) would
look like:
(set! sw (XConfigureEvent-width ev))
This line:
if(ev->window == root && (ev->width != sw || ev->height != sh))
has two struct accesses and one set. So the naive Scheme would probably
take up at least 3 lines. :-)
So that's one area where you'd might want some extra abstraction machinery.
Ed
More information about the Gambit-list
mailing list