| www.delorie.com/gnu/docs/guile/guile_248.html | search |
![]() Buy GNU books! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
sloppy-assq, sloppy-assv and sloppy-assoc behave
like the corresponding non-sloppy- procedures, except that they
return #f when the specified association list is not well-formed,
where the non-sloppy- versions would signal an error.
Specifically, there are two conditions for which the non-sloppy-
procedures signal an error, which the sloppy- procedures handle
instead by returning #f. Firstly, if the specified alist as a
whole is not a proper list:
(assoc "mary" '((1 . 2) ("key" . "door") . "open sesame"))
=>
ERROR: In procedure assoc in expression (assoc "mary" (quote #)):
ERROR: Wrong type argument in position 2 (expecting NULLP): "open sesame"
ABORT: (wrong-type-arg)
(sloppy-assoc "mary" '((1 . 2) ("key" . "door") . "open sesame"))
=>
#f
|
Secondly, if one of the entries in the specified alist is not a pair:
(assoc 2 '((1 . 1) 2 (3 . 9))) => ERROR: In procedure assoc in expression (assoc 2 (quote #)): ERROR: Wrong type argument in position 2 (expecting CONSP): 2 ABORT: (wrong-type-arg) (sloppy-assoc 2 '((1 . 1) 2 (3 . 9))) => #f |
Unless you are explicitly working with badly formed association lists,
it is much safer to use the non-sloppy- procedures, because they
help to highlight coding and data errors that the sloppy-
versions would silently cover up.
assq but does not do any error checking.
Recommended only for use in Guile internals.
assv but does not do any error checking.
Recommended only for use in Guile internals.
assoc but does not do any error checking.
Recommended only for use in Guile internals.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |