[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
dispatching on keywords
- To: firstname.lastname@example.org, Jonathan.Bachrach@ircam.fr, email@example.com
- Subject: dispatching on keywords
- From: Mark Nahabedian <naha@RIVERSIDE.SCRC.Symbolics.COM>
- Date: Fri, 13 Nov 1992 15:09 -0500
- In-reply-to: <9211131645.AA25253@ilog.ilog.fr>
Date: Fri, 13 Nov 1992 11:45 EST
From: firstname.lastname@example.org (Harley Davis)
I think the idea of lexicographical ordering of class names for
computing method specificity is silly --- especially in a system where
class names are optional and documentary.
However, I think there is something which can be saved from the idea
of dispatching on keywords and optional arguments. I think it should
be allowed only if the default value is specified in the generic
function definition rather than in the method definition. This would
not create the sort of ambiguities which Moon and Fahlman mentioned.
My proposal would be that if a default value is specified in a generic
function, it cannot also be specified in one of the gf's methods. If
any method specifies a default value, the generic function cannot.
I think you also need the restriction that if any method specifies a
default for an argument then no method can specialize that argument.
You can't change the arguments after the applicable methods have been
(defgeneric foo (x #optional (y 1))
(defmethod foo (x #optional (y <integer>))
;; default method
(defmethod foo (x #optional (y <string>))
;; could be called if y were supplied by the caller
Obviously there are major syntactic problems to be solved.
... because the syntax for specializing required arguments conflicts
with the syntax for defaulting optional arguments.
I don't understand the motivation for this discussion. I have not yet
needed such a feature. I have always been able to employ a trivial
workaround on the rare occasions when what you're arguing for ha scome
up. (Sorry to be using Lisp syntax here, I don't have a Dylan spec
(defun foo (x &optional (y integer))
(foo-1 x y))
(defgeneric foo-1 (x y))
(defmethod foo-1 (x (y integer))
(defmethod foo-1 (x (y string))