This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: another nit.
hjstein@bfr.co.il writes:
> > > Guile _chooses_ to return a guile-specific object, namely
> > > #<unspecified>.
> >
> > I take it this #<unspecified> or rather SCM_UNDEFINED is here to stay,
> > is it not? In that case, there is no problem, because I can just keep
> > using my own routines instead of assq-ref. (I actually use them from
> > within C only, so I can live with implementation specificness).
>
> You should use assq.
(sigh)
I have a function get_property () that basically boils down to
SCM p = scm_assq (gh_symbol2scm (keyname), alist)
return p == SCM_BOOL_F ? SCM_UNDEFINED : gh_cdr (p)
and lots of code that does
SCM s = get_property ("key");
if (gh_number_p (s))
{
[do special stuff]
}
Removing a property amounts to
alist = gh_acons (key_symbol, SCM_UNDEFINED, alist);
If I were to use assq directly, I would have to do
SCM s = assq ( [stuff] );
if (s != SCM_BOOL_F && gh_number_p (gh_cdr (s)))
{
s = gh_cdr (s);
[do special stuff]
}
which is longer, more clumsy and error-prone. More importantly, I
don't have a means to erase a value from an alist, because my alists
are read-only.
--
Han-Wen Nienhuys | hanwen@cs.uu.nl | http://www.cs.uu/~hanwen/