From my reading of the HyperSpec it seems that you cannot specialize a
method based on keyword arguments. Can someone confirm that this is,
indeed, a correct reading of the `defmethod' entry?
Thanks,
Daniel
--
If a man is pictured chopping off a woman's breast, it only gets a R rating,
but if, God forbid, a man is pictured kissing a woman's breast, it gets an X
rating. Why is violence more acceptable than tenderness?
-- Sally Struthers
From: Erik Naggum
Subject: Re: defmethod and specializing on &key parameters.
Date:
Message-ID: <3226293107597036@naggum.net>
* Daniel Pittman
| From my reading of the HyperSpec it seems that you cannot specialize a
| method based on keyword arguments. Can someone confirm that this is,
| indeed, a correct reading of the `defmethod' entry?
This is explained in clause 7.6 Generic Functions and Methods in the
standard, specifically in 7.6.4 Congruent Lambda-lists for all Methods of
a Generic Function.
///
--
In a fight against something, the fight has value, victory has none.
In a fight for something, the fight is a loss, victory merely relief.
Daniel Pittman <······@rimspace.net> writes:
> From my reading of the HyperSpec it seems that you cannot specialize a
> method based on keyword arguments. Can someone confirm that this is,
> indeed, a correct reading of the `defmethod' entry?
Exactly the required parameters are specializable.
See CLHS 7.6.2 Introduction to Methods or the 'defmethod entry'.
--
"Das Auto hat keine Zukunft. Ich setze aufs Pferd." Wilhelm II. (1859-1941)
From: Tim Moore
Subject: Re: defmethod and specializing on &key parameters.
Date:
Message-ID: <a7vngu$c27$0@216.39.145.192>
On Thu, 28 Mar 2002 18:35:30 +1100, Daniel Pittman <······@rimspace.net> wrote:
>From my reading of the HyperSpec it seems that you cannot specialize a
>method based on keyword arguments. Can someone confirm that this is,
>indeed, a correct reading of the `defmethod' entry?
>
>Thanks,
> Daniel
You can't specialize on keyword arguments, as others have said. If
you want to do that, a common idiom is to split your function into a
function that takes keyword arguments and a generic function called
with sensible defaults by the first function. For example, from McCLIM:
(defun read-gesture (&key
(stream *standard-input*)
timeout
peek-p
(input-wait-test *input-wait-test*)
(input-wait-handler *input-wait-handler*)
(pointer-button-press-handler
*pointer-button-press-handler*))
(stream-read-gesture stream
:timeout timeout
:peek-p peek-p
:input-wait-test input-wait-test
:input-wait-handler input-wait-handler
:pointer-button-press-handler
pointer-button-press-handler))
(defgeneric stream-read-gesture (stream
&key timeout peek-p
input-wait-test
input-wait-handler
pointer-button-press-handler))
Tim