From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mikael Djurfeldt Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.user Subject: Re: Keywords in GOOPS methods Date: Thu, 21 Nov 2024 21:33:09 +0100 Message-ID: References: Reply-To: mikael@djurfeldt.com Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000004cbc190627722d5d" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22873"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Mikael Djurfeldt To: guile-devel , =?UTF-8?Q?Ludovic_Court=C3=A8s?= , guile-user , Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Nov 21 21:33:45 2024 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tEDs1-0005n2-8x for guile-devel@m.gmane-mx.org; Thu, 21 Nov 2024 21:33:45 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tEDrk-0003rP-AQ; Thu, 21 Nov 2024 15:33:28 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tEDrg-0003qg-FE; Thu, 21 Nov 2024 15:33:25 -0500 Original-Received: from mail-ot1-f41.google.com ([209.85.210.41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tEDre-0006Xn-Jn; Thu, 21 Nov 2024 15:33:24 -0500 Original-Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-718186b5c4eso564074a34.2; Thu, 21 Nov 2024 12:33:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732221200; x=1732826000; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Pie/wLoVWfkxivAqv/Vb+7ExMoAZjdyOWSqVZDNd278=; b=V3A04uum1vHclaMvQ7FfUrUEDqnhNRudaYWfbsP9+4jJqdZKtFNrgkvrHISZfJRVCT V5+YVBBqjKYH/dqlGueHY1uzKfVou0gVztFcV6rsUPNjMOOGWoBPruRHKOE6rINyDwaj em7An9b0NY893INgCArLetgfkeFJ+5T3g8gAv5rHYbI/7DewPRZNCBF04IwiLW33aAt7 B5p3MudFHrxwWCl1CSopAK1ruZ8vM9AroL0wau5fvxq01kA/O3F74OdthIZk5tCkZ74O kwuM2x1ucIs43KI9HnQFjhkhUTR64B3l/M+gOkpzEsEmFmOnCUFUct7YVluKGYbfVNHY 2N4g== X-Forwarded-Encrypted: i=1; AJvYcCWqHfjvX05euqTmksSiKwmmOjF1brhRqb/RQ2BU4cCpztZtnJuunenK6XqLJD8NrI2wpvYJjw==@gnu.org, AJvYcCXFnbmQaihCPpJCiJNPv78zB8I6pWNBadEymCwPIg0gTcsr94BOYrazCvFgHitkscXjlPMJYzDkuMTZ@gnu.org X-Gm-Message-State: AOJu0YxRBrdG8JDV+EPQ75WkTzcR9wBuBAcC7foLxbZvOtZdzOOfsQK4 XRftlP5UTNTcEKc71APNb5jWZQ2DZkqNGyNlLBdryLbwa6UJLUYtVeU1nxYGagGqmxWTtF7KwnT EZ1U9scBC5cLzRgPQhqAO3wCzQuk8sk1M X-Gm-Gg: ASbGncv0c0N4Z38Ylb599zBhtD4xjjF1Pa7wgikmsNfrECRYXzupl+IgN8IhPjk3TN0 nt5y+Cj3z47Iete4a8Sp7eVKIQiB/xCYE X-Google-Smtp-Source: AGHT+IFZGsMApPzGjH6Xgpt1O9wXgmKin2kdKoBoco4Dt2aGN16pl+Fz8wnymT3F4Lf3pShyQZlmOqEuJoLCCxmspMM= X-Received: by 2002:a05:6359:1781:b0:1c6:33e8:4b79 with SMTP id e5c5f4694b2df-1ca796ca34cmr79423755d.2.1732221200019; Thu, 21 Nov 2024 12:33:20 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=209.85.210.41; envelope-from=mdjurfeldt@gmail.com; helo=mail-ot1-f41.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22780 gmane.lisp.guile.user:19907 Archived-At: --0000000000004cbc190627722d5d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 ) (topic ) . 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 ) (topic ) #: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=E2=80=AFPM Mikael Djurfeldt 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 (whic= h > 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 > > --0000000000004cbc190627722d5d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Since there are no comments, I'm inclined to appl= y 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 u= se a coding pattern that I tend to use in cases where methods need keyword = arguments:

(define-method (subscribe (client &= lt;mosquitto-client>) (topic <string>) . args)
=C2=A0 (define* = (subscribe #:key (qos 0))
=C2=A0 =C2=A0 (mosquitto_subscribe (mosq clien= t) %null-pointer topic qos))
=C2=A0 (apply subscribe args))
With the change I propose, this can be written:

=
(define-method (subscribe (client <mosquitto-client>) (top= ic <string>) #:key (qos 0))
=C2=A0 (mosquitto_subscribe (mosq clie= nt) %null-pointer topic qos)))

with the same resul= ting semantics.

There is one question that I'd= like people to think about, though: In my patch I have adhered to the clos= e relationship with CLOS, where defmethod takes keyword, optional and rest = arguments similar to Guile's define*, and extended the method syntax it= self. 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 woul= d be cleaner, for example from a backward compatibility perspective. On the= other hand it might feel like overkill to have so much syntax. Implementat= ion 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 t= he implementation...

Best regards,
Mikae= l

On Tue, Nov 19, 2024 at 5:41=E2=80=AFPM Mikael Djurfeldt <mikael@djurfeldt.com> wrote:
<= div>Hi all,

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

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

Comments= ?

Best regards,
MIkael

--0000000000004cbc190627722d5d--