[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: can gh_run_hook return value??
From: |
Neil Jerram |
Subject: |
Re: can gh_run_hook return value?? |
Date: |
05 Jul 2001 20:20:44 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
>>>>> "Martin" == Martin Grabmueller <address@hidden> writes:
>> From: "Dale P. Smith" <address@hidden> Date: Tue, 03 Jul
>> 2001 22:08:18 -0400
>>
>> "M.P.Anand Babu" wrote:
>> > If I run a gh_list_p on hook_return, it returns false !!
>>
>> The return value of scm_run_hook is always SCM_UNPECIFIED.
Martin> I have added information about the return values of the
Martin> hook procedures to the GRM.
The thing with hooks, though, is that on the one hand, they are a
jolly good mechanism for allowing multiple callers (that perhaps don't
"know" about each other) to register for a certain event; but on the
other hand, it does seem desirable for some uses of hooks that the
hook procedures should be able to return a value.
I've been thinking about this recently (in the context of the Guile
debugger) and came up with two possibilities.
The first is `hook-fold', which doesn't exist in Guile yet, but would
work like this: given a hook with three procedures added to it,
(hook-fold hook init . args)
would return
(proc3 (proc2 (proc1 init . args) . args) . args)
The problem with this, though, is that all the hook procedures have to
be designed to understand this behaviour.
The second is:
(catch 'hook-return
(lambda () (run-hook hook args) #f)
(lambda (key value) value))
With this one, as soon as a hook procedure wants to return a value, it
does
(throw 'hook-return value)
subsequent hooks won't be run, of course, but that may in fact be what
you want.
Well, there's my rambling; just in case it helped...
Neil