This is the mail archive of the guile@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: add-hook!


Greg Badros <gjb@cs.washington.edu> writes:

> Perhaps add-hook! could return the procedure that was added -- it would
> facilitate later removing closures that are added.  I could do:
> 
> (define foo (add-hook! window-close-hook (lambda (win) (display win))))
> 
> (remove-hook! foo)

The goal for Guile is to support good programming style, not to save
typing.  `add-hook!' sounds like an operation which adds something to
a hook.  You don't expect it to return anything.

Currently, you can do:

  (define foo (lambda (win) (display win)))
  (add-hook! window-close-hook foo)

  (remove-hook! foo)

To me, this actually looks better than the example above since it is
more readable.

/mdj