I had a look at the bug report bug ID: 893633 "depends(a,[b,b,b])".
The following modification of the the routine i-$dependices does not do
a union between the list of dependencies from the property list and the
arguments to the function depends, but add the dependencies
element-wise. This allows to check for symbols and to remove duplicates.
(defmfun i-$dependencies (l &aux y res)
(dolist (z l)
(cond
((atom z)
(merror (intl:gettext "depends: argument must be a non-atomic
expression; found ~M") z))
((or (eq (caar z) 'mqapply) (member 'array (cdar z) :test #'eq))
(merror (intl:gettext "depends: argument cannot be a subscripted
expression; found ~M") z))
(t
(setq y (reverse (mget (caar z) 'depends)))
(do ((zz z (cdr zz)))
((null zz)
(mputprop (caar z) (setq y (reverse y)) 'depends)
(setq res (push (cons (ncons (caar z)) y) res))
(unless (cdr $dependencies)
(setq $dependencies '((mlist simp))))
(add2lnc (cons (cons (caar z) nil) y) $dependencies))
(cond ((not (symbolp (cadr zz)))
(merror
(intl:gettext "depends: argument must be a symbol;
found ~M")
(cadr zz)))
((and (cadr zz)
(not (member (cadr zz) y)))
(setq y (push (cadr zz) y))))))))
(cons '(mlist simp) (reverse res)))
The results for the bug report are:
(%i1) depends(a,[b,b,b]);
(%o1) [a(b)]
(%i2) dependencies;
(%o2) [a(b)]
(%i3) depends(f,x*y);
depends: argument must be a symbol; found x*y
-- an error. To debug this try: debugmode(true);
We get an error when the argument is not a symbol. Multiple dependencies
are ignored and not added to the property list of the symbol.
There are two changes in the output visible to the user:
1. depends now add the new dependencies always at the end of the
property list.
2. The return value of depends shows the complete dependencies,
including the dependencies already on the property list.
(%i4) depends(f,[x,y]);
(%o4) [f(x,y)]
(%i5) depends(f,[a,b]);
(%o5) [f(x,y,a,b)]
I think both changes make the function depends even more consistent.
Dieter Kaiser