This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: another nit.
- To: "Harvey J. Stein" <hjstein at bfr dot co dot il>
- Subject: Re: another nit.
- From: Jonathan Bartlett <johnnyb at wolfram dot com>
- Date: Thu, 6 Jul 2000 04:10:51 -0500 (CDT)
- cc: Michael Livshin <mlivshin at bigfoot dot com>, Dirk Herrmann <dirk at ida dot ing dot tu-bs dot de>, Han-Wen Nienhuys <hanwen at cs dot uu dot nl>, Guile Mailing List <guile at sourceware dot cygnus dot com>
What does vector-ref return when someone accesses it beyond a valid index?
Whatever this behavior is, should also be the behavior of assq-ref.
Jon
On 6 Jul 2000, Harvey J. Stein wrote:
> 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
>