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.


Michael Livshin <mlivshin@bigfoot.com> writes:

 > I think `assq' is good enough.  millions^Wthousands^Wlots of Lisp
 > users that live with the convention of returning #f (or nil) when a
 > key does not exist don't seem to mind much.

The argument was about assq-ref, not assq.  assq is invertible because
it returns the list element (a pair) whose car matches the key and #f
if nothing matches.  So it returns #f iff the key isn't in the list.

As for assq-ref, I guess it'd be convenient for it to match common
hashtable interfaces, namely to have an extra optional argument to
specify what to return if the key isn't found.  It's also not uncommon
to throw an error if the key isn't found & the optional argument isn't
supplied.  This would give something for everybody.

However, given the existence of assq, I don't see the point.  Why not
just use assq if you need to know whether or not the key is in the
list?

-- 
Harvey Stein
Bloomberg LP
hjstein@bfr.co.il

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