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=)
when collector
collect (coerce collector 'string) into result
and do (setq collector nil) end
else
collect char into collector
finally (return (if collector
(append result (list (coerce collector 'string)))
result))))
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.
Any hints?
Thanks,
Edi.
--
Lisp is not dead, it just smells funny.
Real email: (replace (subseq "spamtrap@xxxxxxxxxx" 5) "edi")
.
- Follow-Ups:
- Re: Illegal LOOP usage?
- From: Rob St. Amant
- Re: Illegal LOOP usage?
- From: Tim Bradshaw
- Re: Illegal LOOP usage?
- From: Alex Mizrahi
- Re: Illegal LOOP usage?
- From: Dmitriy Ivanov
- Re: Illegal LOOP usage?
- From: Madhu
- Re: Illegal LOOP usage?
- Prev by Date: Re: Using SBCL in debian
- Next by Date: Re: Illegal LOOP usage?
- Previous by thread: wierd formatting
- Next by thread: Re: Illegal LOOP usage?
- Index(es):
Relevant Pages
|