Since there are no comments, I'm inclined to apply this patch. I will do that on Sunday if there are no comments before that.

Maybe I should first give a motivating example: guile-mqtt consists of a thin wrapper over NYACC-generated code. There, I use a coding pattern that I tend to use in cases where methods need keyword arguments:

(define-method (subscribe (client <mosquitto-client>) (topic <string>) . args)
  (define* (subscribe #:key (qos 0))
    (mosquitto_subscribe (mosq client) %null-pointer topic qos))
  (apply subscribe args))

With the change I propose, this can be written:

(define-method (subscribe (client <mosquitto-client>) (topic <string>) #:key (qos 0))
  (mosquitto_subscribe (mosq client) %null-pointer topic qos)))

with the same resulting semantics.

There is one question that I'd like people to think about, though: In my patch I have adhered to the close relationship with CLOS, where defmethod takes keyword, optional and rest arguments similar to Guile's define*, and extended the method syntax itself. As an alternative, we could let the current method syntax stay as is and implement new define-method* and method* syntax. In some ways this would be cleaner, for example from a backward compatibility perspective. On the other hand it might feel like overkill to have so much syntax. Implementation and performance wise it shouldn't matter much how we choose to do, except that adding define-method* and method* of course adds more code to the implementation...

Best regards,
Mikael

On Tue, Nov 19, 2024 at 5:41 PM Mikael Djurfeldt <mikael@djurfeldt.com> wrote:
Hi all,

I've implemented support for keyword arguments (corresponding to define* and lambda*) in GOOPS. The functionality is similar to that of CLOS (which also has keyword in methods) in that dispatch is not done on the keyword part.

You can find the changes in the goops-keyword branch at https://github.com/mdjurfeldt/guile/tree/goops-keyword or in the included patch.

Comments?

Best regards,
MIkael