Keywords in define-method

Mikael Djurfeldt <[email protected]>
Newsgroups gmane.lisp.guile.devel,gmane.lisp.guile.user
Message-ID <CAA2XvwJKag7oMWKa2NXsVgbDOn1=HjTA+k7dXrign1OrkgQhYA@mail.gmail.com>
On Fri, Nov 22, 2024 at 1:20 PM <[email protected]> wrote:

> ...which I think in your version, not having to use define-method*
> feels more elegant/GOOPSy to me, as it's all overloads/generics,
> but I have no strong opionion on this.
>

There's actually a secret to what I have committed:

define-method* *is* the define-method you requested.

So you can do, e.g.:

(use-modules ((oop goops)
              #:hide (define-method)
              #:renamer (lambda (s) (if (eq? s 'define-method*)
'define-method s))))

or

(define-module (foo)
  #:use-module ((oop goops)
                #:hide (define-method)
                #:renamer (lambda (s) (if (eq? s 'define-method*)
'define-method s))))

and then

(define-method (bar #:key x) x)

For ordinary formals, like

(define-method (baz x) ...)

the resulting behavior and efficiency will be very close to identical. The
compiled code and type dispatch of the method will be identical to that
produced by the original define-method macro.

Best regards,
Mikael
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.