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

porting



        Here are two differences between lucid and allegro that I
noticed.

1.  In allegro (and some other lisps I tried) (remove foo list) 
always returns a copy of list, even if foo is
not in  list. This is not true for lucid. So

(let ((list '(a b c)))
     (eq list (remove 'd list)))

returns nil with allegro but t with lucid. The second edition of
Steele makes it clear that an implementation is not required to return
a copy if nothing is removed, so neither one is wrong. In my opinion
it would have been a better choice to always require that remove 
return a copy of list. This allows a function to
safely modify a list by first doing a remove and then a series of
deletes. But this won't work if you can't guarantee that the remove
doesn't actually remove something.

2. The effect of

(remove-duplicates list :from-end t :test #'(lambda (x y) (mytest x y)))

in allegro is the same as

(remove-duplicates list :from-end t :test #'(lambda (y x) (mytest x y)))

in lucid (and vise versa).  This is pretty obscure since usually mytest
will be some equality-like predicate so (mytest x y) = (mytest y x).
However there are some uses of this when "mytest" is not symmetric,
eg. you can find the minimal sets from a list of sets by apply
remove-duplicates twice, once with :from-end t, using a test based
on subsetp. "Common Lisp, the Reference" states clearly that allegro 
is right but Steele is less definitive.

		Ralph Freese
		Dept. of Math.
		Univ. of Hawaii
		Honolulu, HI.
		ralph@kahuna.math.hawaii.edu