[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Delete bug



>     First, I lost the address to send bug reports to.  Can somebody repost it
>please?  Second, there is a bug in the delete function.  It works properly if
>any item in a sequence is deleted except for the first item.  In that case, it
>acts just like remove (i.e., it non-destructively modifies the sequence).  For
>example:
>
>? (setq x '(13 5 7 16 9))
>(13 5 7 16 9)
>? (delete 5 x)
>(13 7 16 9)
>? x
>(13 7 16 9)
>? (delete 13 x)
>(7 16 9)
>? x
>(13 7 16 9)
>
>By the way, I am running MCL 2.0b1p3 on a MacII under System 6.0.3.
>
>Jerry James
>jamesj@bert.cs.byu.edu

This is a common misunderstanding of destructive functions...

When CLtL says that DELETE is a destructive function, all it
says is that DELETE can modify the structure of its list argument
to get the result faster. You still have to take the result
from the function. (i.e. (setq x (delete 3 x))).

If fact what you are asking DELETE to do is impossible!
Consider the following:
  ? (setq x '(3))
  (3)
  ? (delete 3 x)
  ()
  ? x
  (3)
DELETE being a function receives as argument the list (3).
It no way can it know that it has to change the value of x!
It would have to be defined as macro (as INCF) to be able
to change the value of x.

Hope this all makes sense.
Guillaume.

Guillaume Cartier
LACIM, Universite du Quebec a Montreal.
Bureau: (514) 987-4290
E-Mail: cartier@math.uqam.ca