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: another nit.


Craig Brozefsky <craig@red-bean.com> writes:

> Dirk Herrmann <dirk@ida.ing.tu-bs.de> writes:
> 
> > On Thu, 6 Jul 2000, Han-Wen Nienhuys wrote:
> > 
> > > why do assq-ref and friends return #f when the key is not found, in
> > > stead of #<unspecified>? This makes it kind of hard to distinguish
> > > between an alist not containing KEY and  (KEY . #f)
> 
> This entire thread is based on a misunderstanding by Han-Wen.  assq
> does NOT return just the cdr of the pair whose car is KEY, but the
> whole pair, and therefor it's quite easy to see if the alist did NOT
> contain the key at all, or if it's value is #f.

Han-wen has mailed me indicating that it was the ass{??}-ref family of
functions he was talking about, whereas I thought he was talking about
the ass{??} functions themselves when he said "assq-ref and freinds".

The ass{??}-ref functions are not in R5RS standards and I'm not sure
what the purpose of it is, since the ass{??} functions themselves
basically provide a complete interface to association lists.  That
said, if guile does add it, I would suggest it uses the same argument
ordering as other <blah>-ref functions, which is what it currently
does.  As for what it should return if the KEY is not available, I'd
think it would be best to match the behavior of hash tables as closely
as possible, which is to return #f.  This is what it currently does.

This way, you have a hash table compatable interface that allows you
to easily switch between assoc lists and hash tables, but you also
have the original ass{??} functions which give you a full interface to
association lists, including identifying when a key was not found.

-- 
Craig Brozefsky               <craig@red-bean.com>
Lisp Web Dev List  http://www.red-bean.com/lispweb
---  The only good lisper is a coding lisper.  ---

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