Sloppy Alist Functions
......................
`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.
- primitive: sloppy-assq key alist
Behaves like `assq' but does not do any error checking.
Recommended only for use in Guile internals.
- primitive: sloppy-assv key alist
Behaves like `assv' but does not do any error checking.
Recommended only for use in Guile internals.
- primitive: sloppy-assoc key alist
Behaves like `assoc' but does not do any error checking.
Recommended only for use in Guile internals.