[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hook change hook?
From: |
Neil Jerram |
Subject: |
Re: Hook change hook? |
Date: |
28 Feb 2002 19:52:43 +0000 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
>>>>> "Marius" == Marius Vollmer <address@hidden> writes:
Marius> Neil Jerram <address@hidden> writes:
>> When working with hooks, I often find that I have to wrap access to
>> the hook rather than making the hook available directly, because I
>> need to do something extra whenever something is added or removed from
>> that hook.
Marius> How about goopsifying hooks so that add-hook is a generic function?
I just tried to do this - i.e. making all the primitives in hooks.c
generic except for `make-hook'. Unfortunately it isn't
straightforward because `add-hook!' has arity (2,1,0), and
create_gsubr_with_generic doesn't support functions with this arity.
I can think of various kludges (e.g. use arity (2,0,1) or (3,0,0)
instead and maybe provide a Scheme wrapper in boot-9.scm). For a
clean solution I guess we should either add a new scm_tc7_subr_3o type
to the code (scary), or support genericization of cclos (also scary).
Any other ideas?
Neil
PS. For future reference, here's the SCM_GDEFINE definition that I
added to snarf.h to try this out:
#define SCM_GDEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \
SCM_SNARF_HERE(\
static const char s_ ## FNAME [] = PRIMNAME; \
static SCM g_ ## FNAME; \
SCM FNAME ARGLIST\
)\
SCM_SNARF_INIT(\
scm_c_define_gsubr_with_generic (s_ ## FNAME, REQ, OPT, VAR, \
(SCM_FUNC_CAST_ARBITRARY_ARGS) FNAME, \
& g_ ## FNAME); \
)\
SCM_SNARF_DOCS(primitive, FNAME, PRIMNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING)