From Newsgroup: comp.lang.lisp
B. Pym wrote:
Peter Seibel wrote:
Kenny Tilton <ktilton@nyc.rr.com> writes:
Cool. Now here is a version using loop:
(defun remove-text (text-to-remove text)
(loop with remove-length = (length text-to-remove)
for i = (search text-to-remove text)
then (search text-to-remove text :start2 i)
while i
do (setq text (concatenate 'string
(subseq text 0 i)
(subseq text (+ i remove-length))))
finally (return text)))
Just to point out a useful LOOP idiom, here's another way:
(defun remove-text (text-to-remove text)
(with-output-to-string (s)
(loop
with remove-length = (length text-to-remove)
for prev-end = 0 then (+ start remove-length)
for start = (search text-to-remove text :start2 prev-end)
do (write-string text s :start prev-end :end start)
while start)))
It can be made shorter if we use a Lispy language instead of CL.
Gauche Scheme
(use srfi-13) ;; string-contains
(use gauche.sequence) ;; size-of (instead of string-length)
(define (remove-text trash text)
(with-output-to-string (^()
(while text
(let1 found (string-contains text trash)
(display (string-copy text 0 found))
(set! text
(and found (subseq text (+ found (size-of trash))))))))))
Paul Graham:
I consider Loop one of the worst flaws in CL, and an example
to be borne in mind by both macro writers and language designers.
Jeffrey M. Jacobs:
I think CL is the WORST thing that could possibly happen to LISP.
In fact, I consider it a language different from "true" LISP.
Daniel Weinreb, 24 Feb 2003:
Having separate "value cells" and "function cells" (to use
the "street language" way of saying it) was one of the most
unfortunate issues. We did not want to break pre-existing
programs that had a global variable named "foo" and a global
function named "foo" that were distinct. We at Symbolics
were forced to insist on this, in the face of everyone's
knowing that it was not what we would have done absent
compatibility constraints. It's hard for me to remember all
the specific things like this, but if we had had fewer
compatibility issues, I think it would have come out looking
more like Scheme in general.
Paul Graham, May 2001:
A hacker's language is terse and hackable. Common Lisp is not.
The good news is, it's not Lisp that sucks, but Common Lisp.
--- Synchronet 3.21a-Linux NewsLink 1.2