[iterate-devel] for var in non-list

Attila Lendvai attila.lendvai at gmail.com
Fri Jun 30 22:09:28 UTC 2006


hi!

the (for var in list) clause silently skips non-lists. after a quick
look i saw this in the sources:

;;; This is so the advanced user can choose how the end of a list is checked
;;; for.
;;; There are three choices for termination predicate in FOR...ON and
;;; FOR...IN, differing in their behavior on lists with a non-nil cdr:
;;;    NULL: If lucky, will get an error when taking the cdr.  Bad choice.
;;;    ATOM: Will terminate correctly with no error.
;;;    ENDP: Will give an appropriate error message.

(defparameter *list-end-test* 'atom)

1) why is 'atom the default and not 'endp? it's not that hard to
accidentally pass in a vector instead of a list... and then it's just
silently skipped. imho 'endp as the default is much more reasonable,
unless i miss something.

2) thinking this further, (for in) could even be smart enough to work
on all kind sequences (possibly specializing for list at runtime to
avoid elt-ing lists) and an in-list/on-list could be introduced for
the current (for in) behaviour? this leads a bit far, though...

any opinions? i think if there's no huge performance penalty then we
should change 1 to use 'endp.

-- 
- attila

"- The truth is that I've been too considerate, and so became
unintentionally cruel...
 - I understand.
 - No, you don't understand! We don't speak the same language!"

Ingmar Bergman - Smultronstället (Wild Strawberries)


More information about the iterate-devel mailing list