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: Unwanted hook names (was Re: interface reductions)


Dirk Herrmann <dirk@ida.ing.tu-bs.de> writes:

> > I think that there generally should be functions behind most snarf
> > macros.  For example, there are instances where you need to use
> > scm_make_subr_opt instead of using snarf macros.
> 
> Right, but in my personal opinion it would make sense to separate the
> concepts of creating an object and creating a global (or
> module-global) binding for an object.  This is because I prefer to have a
> function that makes a subr, and nothing else, and then to create a binding
> for it, in contrast to a beast like scm_make_subr_opt that does it all,
> but controlled by flags.  But this leads us to a completely different
> topic :-)

How about the following set of functions and a macro?

SCM scm_c_make_hook (int n_args);
void scm_c_set_object_name (SCM obj, const char *name);
void scm_c_environment_define (SCM env, const char *name, SCM obj);

#define SCM_DEFINE_HOOK(CNAME, ENV, SNAME, NARGS, DOCS) \
SCM_SNARF_DECL(                                         \
  SCM CNAME                                             \
)                                                       \
SCM_SNARF_INIT(                                         \
  CNAME = scm_c_make_hook (NARGS);                      \
  scm_c_set_object_name (CNAME, SNAME);                 \
  scm_c_environment_define (ENV, SNAME, CNAME);         \
)                                                       \
SCM_SNARF_DOCS(...)

scm_c_environment_define will call scm_protect_object if necessary.
In my feeling, I don't think scm_create_hook is really necessary.
One can make it by myself if one wants it.

-- Kei

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