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:

> > 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);
> 
> That's (almost) what I was thinking of.  Remembering also Greg's and
> Marius' point about the nice debugging features if objects get a name by
> default, we could think of a debugging option SCM_DEBUG_OBJECT_NAMES,
> which in debugging mode gives all objects created by snarf macros the
> corresponding names (just an idea:  it's either stupid or could even be 
> improved on...).  The functions for creating bindings in some
> environment are, however, already defined and implemented by Jost.  But,
> the separation of object creation and binding might be helpful in
> combination with the new environments and with any future work on the
> environment and module system:  a) Different concepts are no longer
> intermingled.  b) if there are new options and parameters necessary to
> create a binding, we don't have to change all object-creating interfaces,
> since these don't have anything to do with it any more.

I think it is okay to give names to procedures, macros, hooks, and some
others by default without enabling the debug flag.  If one really does
not want to do that, one can do that by not using the standard macro.

> Actually, I wouldn't want scm_c_environment_define (I don't know how this
> will be called with the new environments) to protect the object:  You 
> only need to protect objects that are referenced by C variables that are
> not visible to the gc.  However, the function scm_c_environment_define may
> also be called if there is no global C variable binding created.  Thus, it
> should be the responsibility of SCM_DEFINE_HOOK to do this.  My suggestion
> thus is: 

I see.  So you are protecting a hook rather than the vcell of a hook.
I guess scm_create_hook should protect hook instead of vcell, shouldn't it?

 SCM
 scm_create_hook (const char* name, int n_args)
 {
   SCM vcell = scm_sysintern0 (name);
   SCM hook = make_hook (SCM_MAKINUM (n_args), "scm_create_hook");
   SCM_SETCDR (vcell, hook);
 
   scm_set_object_property_x (hook, scm_makfrom0str ("name"), scm_makfrom0str (name));
-  scm_protect_object (vcell);
+  scm_protect_object (hook);
 
   return hook;
 }

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