This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: hook? primitive


Mikael Djurfeldt <mdj@mdj-pc.nada.kth.se> writes:

> Greg Badros <gjb@cs.washington.edu> writes:
> 
> > > 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.
> 
> I think a better solution in this case would be to store the
> information you need for filtering in some kind of table.
> 
> I'm not convinced that hook-arity is useful enough to balance the
> costs of increased complexity.

But the printable form even includes the arity in it.  The bottom line
is: users of guile are going to use:

(cadr some-random-hook)

to get at the hook arity.  To provide a reasonable abstraction of hooks, 
that implementation detail needs to be hidden behind a provided
procedure.

Greg

P.S.  What complexity?  It's a simple accessor primitive that can be
orthogonally ignored, if desired.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]