[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Differences between gh_lookup and scm_c_lookup
From: |
Marius Vollmer |
Subject: |
Re: Differences between gh_lookup and scm_c_lookup |
Date: |
17 Jun 2001 13:51:29 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.102 |
"Dale P. Smith" <address@hidden> writes:
> Since the gh_ interface is going to be going away sometime, I
> started converting some code to use a scm_* or scm_c_* interface.
> Looking for a replacement for gh_lookup I found scm_c_lookup. My
> code wasn't working though. I finally noticed that gh_lookup does a
> SCM_VARIABLE_REF on the returned value while scm_c_lookup does not.
>
> Bug or by design?
By quick and dirty design.
> Another difference is that gh_lookup returns SCM_UNDEFINED on an error,
> while scm_c_lookup calls scm_misc_error.
>
> I think the gh_ method is easier to handle from C.
Hmm, yes, it depends, I'd say. There are a lot of options when it
comes to looking something up: should the name be a string or a
symbol; should a error be signalled when no bindings is found or
should SCM_UNDEFINED be returned; should the variable be returned or
its value; should a error be signalled when the bound thing is not a
variable, but something else.
Regarding returning value or variable, I think I agree that returning
the value is better, since for using the variable correctly one would
have to follow a involved protocol (which doesn't exist yet) so that
changes to the bindings are picked up.
I think, however, that we shouldn't return SCM_UNDEFINED instead of
throwing an error in the default case. It should be possible to get
both behaviours so that we can avoid putting the burden for producing
a sensible error message on the caller at all times.
So, what about adding a function scm_c_module_lookup_generic that will
lookup everything in a given module and return SCM_UNDEFINED in case
no binding is found? On top of that, we could have scm_c_lookup_value
which would return the value.