This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: hook? primitive
Mikael Djurfeldt <mdj@mdj-pc.nada.kth.se> writes:
> Greg Badros <gjb@cs.washington.edu> writes:
>
> > > Is it really useful in practice?
> >
> > Yes, most definitely. I need empty-hook? in Scwm for knowing whether I
> > should XSelectInput on MotionNotify events or not.
>
> OK, I'll add this (grumble, grumble). :)
> (But I'll call it hook-empty?. The normal convention is to prefix
> operations with the type name (except for set!). add-hook! & co are
> exceptions motivated by history.)
Yep. Agreed (that's what I had it as, in fact, I just mis-wrote).
> > And the arity is essential for supporting a UI that permits
> > interactively adding apropriate procedures to the various supported
> > hooks (we can filter the potential procs based on their arity
> > matching the arity of the hook we're manipulating.)
>
> I don't understand this. add-hook! will throw an error if you try to
> add a procedure with the wrong arity. Isn't that enough?
I *could* get what I need with that, but at way too much run-time
expense. If I want to present the user with a dialog box with a list of
the procedures that could be added to a given hook (say the
window-close-hook), I definitely don't want to try adding each proc to
the hook and see if I get the exception, and if not, then remove the
proc, just to decide whether each of the thousands of procedures
available should be in the dialog.
Of course, I could hack something together that would try a proc of
length 1, then of 2, then of 3, etc., until I find the right number, but
that's a really screwey and roundabout way to do this when the primitive
is only a couple words of code.
Greg