unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mikael Djurfeldt <mikael@djurfeldt.com>
To: guile-devel <guile-devel@gnu.org>,
	"Ludovic Courtès" <ludo@gnu.org>, guile-user <guile-user@gnu.org>,
	"Andy Wingo" <wingo@pobox.com>
Subject: Re: Keywords in GOOPS methods
Date: Thu, 21 Nov 2024 21:33:43 +0100	[thread overview]
Message-ID: <CAA2XvwK7NG-Od6p4nSF=xbCj-nEbs=FUnq5hSe8bX_pHC=1f0w@mail.gmail.com> (raw)
In-Reply-To: <CAA2XvwK+9s6rzJGZyXVgwdWscO8v9oByjbhoVH5RrCwHWhepCg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2332 bytes --]

(I will of course add proper documentation in the manual, etc.)

On Thu, Nov 21, 2024 at 9:33 PM Mikael Djurfeldt <mikael@djurfeldt.com>
wrote:

> 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
>>
>>

[-- Attachment #2: Type: text/html, Size: 3243 bytes --]

  reply	other threads:[~2024-11-21 20:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-19 16:41 Keywords in GOOPS methods Mikael Djurfeldt
2024-11-21 20:33 ` Mikael Djurfeldt
2024-11-21 20:33   ` Mikael Djurfeldt [this message]
2024-11-21 22:00   ` janneke
2024-11-21 22:51     ` Mikael Djurfeldt
2024-11-22 11:46       ` Tomas Volf
2024-11-22 12:28         ` Mikael Djurfeldt
2024-11-22 12:20       ` janneke
2024-11-22 12:29         ` Mikael Djurfeldt
2024-11-22 23:04           ` Mikael Djurfeldt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAA2XvwK7NG-Od6p4nSF=xbCj-nEbs=FUnq5hSe8bX_pHC=1f0w@mail.gmail.com' \
    --to=mikael@djurfeldt.com \
    --cc=guile-devel@gnu.org \
    --cc=guile-user@gnu.org \
    --cc=ludo@gnu.org \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).