3 ms·
Does anyone happen to know why e-lisp iterators stop on a magic `iter-end-of-sequence` instead of on `nil`? That doesn't seem Lispy.
by samatman 8y ago
Does anyone happen to know why e-lisp iterators stop on a magic `iter-end-of-sequence` instead of on `nil`? That doesn't seem Lispy.
- dang 8y agoProbably because the sequence might contain nil as an element, and you don't want to short-circuit the iteration when that's the case. For the same reason, it's the usual thing in Lisps to break on a sentinel value (defaulting to EOF or similar) when reading sexprs from a file. In cases where nil isn't a valid element, you can always specify nil as the sentinel.
- cobbal 8y agoA likely reason is that it makes it possible to iterate through a list like `'((1 2) () (a b c))`. If you have to do in-band signaling, make it something unique and obscure.
- kwoff 8y agoIn addition to the sentinel/in-band replies, they also put properties on that symbol: https://github.com/emacs-mirror/emacs/blob/81b5131e11fa96d32a1718c6e2ebf40994d7d281/lisp/emacs-lisp/generator.el#L569 https://github.com/emacs-mirror/emacs/blob/81b5131e11fa96d32... ( https://www.gnu.org/software/emacs/manual/html_node/elisp/Symbol-Plists.html https://www.gnu.org/software/emacs/manual/html_node/elisp/Sy... )