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

Is it possible to use deftyped types as parameter-specializers?



Consider the following:
	(deftype symbol-or-string () '(or symbol string))
	(deftype non-nil-symbol-or-string () 
	  '(satisfies non-nil-symbol-or-string))

	(defun non-nil-symbol-or-string (x) 
	  (if (and (typep x 'symbol-or-string) (not (null x))) t nil))

Suppose I wanted a method to be applicable only when its argument is of 
type non-nil-symbol-or-string.  If non-nil-symbol-or-string were a class 
then the method I want would look like:
	(defmethod meth ((arg non-nil-symbol-or-string))
	  (format t "~A is a non-nil symbol or a string.~%" arg))

Is this possible in clos?  If so, is it implemented in pcl?  If not, then 
why; must not implementations of clos coerce predefined cl types into 
classes (such as symbol and string)?  Why not allow another 
parameter-specializer-name like: (type form) where the value of form is 
a known common lisp type?


Thanks,
Darrell Shane
RAND Corp.