Illegal LOOP usage?
- From: Edi Weitz <spamtrap@xxxxxxxxxx>
- Date: Wed, 07 Mar 2007 01:21:14 +0100
So, this function from Drakma
(defun split-string (string &optional (separators " ,-"))
"Splits STRING into substrings separated by the characters in the
sequence SEPARATORS. Empty substrings aren't collected."
(loop for char across string
when (find char separators :test #'char=)
collect (coerce collector 'string) into result
and do (setq collector nil) end
collect char into collector
finally (return (if collector
(append result (list (coerce collector 'string)))
works as intended with LispWorks, but doesn't work with AllegroCL or
SBCL. It seems the latter two simply ignore the (SETQ COLLECTOR NIL)
form. My guess is that the code above is somehow incorrect in that it
modifies a variable which is used in a "collect ... into ..." clause,
but I couldn't find anything in the CLHS that explicitly says so.
Lisp is not dead, it just smells funny.
Real email: (replace (subseq "spamtrap@xxxxxxxxxx" 5) "edi")