[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Is it possible to use deftyped types as parameter-specializers?
- To: CommonLoops.pa@Xerox.COM
- Subject: Is it possible to use deftyped types as parameter-specializers?
- From: Darrell <email@example.com>
- Date: Wed, 15 Mar 89 14:00:13 PST
- Cc: Gregor.pa@Xerox.COM, Darrell_Shane <firstname.lastname@example.org>
- Redistributed: CommonLoops.pa
Consider the following:
(deftype symbol-or-string () '(or symbol string))
(deftype 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?