1 Nov 2006 09:58
Re: Unified way to access the method name or generic inside from a method
Masatake YAMATO <jet <at> gyve.org>
2006-11-01 08:58:36 GMT
2006-11-01 08:58:36 GMT
> 3. Writing more tricky macros as part of a library
>
> (After thinking what I want is not `retry-method'. What I think useful are
> following special local variables:
>
> - `current-generic'
> - `current-arguments'
> These are more generic.)
>
> With `current-generic' and `current-arguments', people can implement more tricky macros
> in a LIBRARY.
After re-thinking I found the way to provide `current-generic' and `current-arguments'
with a macro which expends `define-method'.
gosh> (define-method* foo (n m) (apply current-generic (cons 3 current-arguments)))
#<generic foo (5)>
gosh> (define-method* foo (n m x) (+ n m x))
#<generic foo (5)>
gosh> (foo 1 2)
6
gosh>
(define-macro define-method*
(lambda (name specs . body)
`(define-method ,name ,specs
(let ((current-generic ,(if (symbol? name)
name
(car name)))
(current-arguments ,(let1 args (cond
(Continue reading)
RSS Feed