[sicl-devel] append and (loop ... append ...)

Robert Strandh strandh at labri.fr
Tue May 11 15:31:30 UTC 2010


Hello everyone,

As you might have noticed, I consider LOOP to be very low level.  By
doing it this way, we can implement higher-level list functions and
sequence functions using loop.  

However, today I implemented the APPEND function like this:

  (defun append (&rest lists)
    (loop for list in lists
          append list))

which is supposed to work.  But I had a problem with structure
sharing.  This is supposed to yield T:

  (let ((list1 '(1 2))
        (list2 '(2 4)))
    (eq list2 (cddr (append list1 list2))))

Unfortunately, it doesn't on SBCL because SBCL (loop ... append ...)
does not "behave as if the APPEND function had been used" which is
what the standard says it must.  

I added a test to check for this.  And we must pay attention to
respect this constraint when we implement SICL LOOP. 

-- 
Robert Strandh

---------------------------------------------------------------------
Greenspun's Tenth Rule of Programming: any sufficiently complicated C
or Fortran program contains an ad hoc informally-specified bug-ridden
slow implementation of half of Common Lisp.
---------------------------------------------------------------------




More information about the sicl-devel mailing list