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:

> Supporting good programming style is different from mandating good
> programming style by making some constructs more awkward to use.
>
> [...]
>
> (define my-hook-remove-handle 
>     (add-hook! window-close-hook 
>        (lambda (win) (display win))))
> 
> my-hook-remove-handle has different semantics from the `foo' symbol --
> it *so* *happens* that it is the procedure, but the API can specify that 
> it's simply something that can be used as an argument to remove-hook!
> instead of the procedure.  You can look at it as an implementation
> detail that it is really the procedure.

Are you suggesting that the above usage pattern should be mandatory?

If we say in the API that remove-hook! takes what is returned from
add-hook! as argument, but the implementation allows for procedure
objects to be passed to remove-hook!, people might still be very
easily mislead to believe that it is OK to pass the procedure.

Then, when the day comes when we make use of what we said in the
spec... crash!

BTW, I don't see why it would be useful to pass something different
than the procedure.