From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxime Devos via General Guile related discussions Newsgroups: gmane.lisp.guile.user,gmane.lisp.guile.devel Subject: RE: Keywords in GOOPS methods Date: Sat, 23 Nov 2024 16:31:42 +0100 Message-ID: <20241123163143.gFXi2D00541pia201FXiCK@xavier.telenet-ops.be> References: <87iksg2qnm.fsf@gnu.org> Reply-To: Maxime Devos Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14884"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-devel , =?utf-8?Q?Ludovic_Court=C3=A8s?= , guile-user , Andy Wingo , Mikael Djurfeldt To: "mikael@djurfeldt.com" , "janneke@gnu.org" Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Nov 23 16:37:15 2024 Return-path: Envelope-to: guile-user@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 1tEsC9-0003gm-Qh for guile-user@m.gmane-mx.org; Sat, 23 Nov 2024 16:37:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tEsBr-00086m-3h; Sat, 23 Nov 2024 10:36:55 -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 1tEsBo-00086I-Ot for guile-user@gnu.org; Sat, 23 Nov 2024 10:36:52 -0500 Original-Received: from xavier.telenet-ops.be ([2a02:1800:120:4::f00:14]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tEsBl-0008PD-V1 for guile-user@gnu.org; Sat, 23 Nov 2024 10:36:52 -0500 Original-Received: from [IPv6:2a02:1811:8c0e:ef00:d8bc:6eed:a17e:32a] ([IPv6:2a02:1811:8c0e:ef00:d8bc:6eed:a17e:32a]) by xavier.telenet-ops.be with cmsmtp id gFXi2D00541pia201FXiCK; Sat, 23 Nov 2024 16:31:43 +0100 Importance: normal X-Priority: 3 In-Reply-To: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r24; t=1732375903; bh=Kes4xbltc6Nx+3zLzy/jufBTP4yLhifI7p+oYpMHZsc=; h=Message-ID:MIME-Version:To:Cc:From:Subject:Date:In-Reply-To: References:Content-Type:From; b=I1l9gMeJURt704NikK21hgjsquPhMNmzuBf9lByg25NaYcji4OZ6vjK06AH5mvwr0 WZW5GDVqNOecOE3Y7splGyxfMryJv/V1lrQKdAHlRNt1bk+MAUF+xVUAnXFU2+qXoY eFxnB0qOipRIv/ufbVAwMIJdnlFcSqx4aq0VjpaYpnNqo1d2kvxneD8+9hAXERbjte IdYuU6B7cTd7trErb2aq3nx8z4s/P/VldiUxXX9frcIDdZ7Vfb1LV9T4HW9cgtLdFb 9mr3ej69Yz/NQptI483AtFqGlfFlkduisidohTP9aZjQzqnKCskRyVWDIlJPlqgMOw 3B+97bzkYwCHw== Received-SPF: pass client-ip=2a02:1800:120:4::f00:14; envelope-from=maximedevos@telenet.be; helo=xavier.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19916 gmane.lisp.guile.devel:22789 Archived-At: >Any opinions on what is best: Having a define-method* or having the functi= onality in define-method itself? You can=E2=80=99t unify define-method with define-method* without making so= me arbitrary choices in some special cases (the same applies to define-meth= od* too actually, and also to define-method on its own without keyword argu= ments, but it needs to be considered and documented somewhere). Consider (please ignore syntax errors, don=E2=80=99t have much practice wit= h GOOPS): (define-method (f (a ) (b )) (pk 'positional a b)) ;; what I mean is to only consider =E2=80=98foo=E2=80=99 that are of class = , I don=E2=80=99t mean as default value (define-method (f (#:key foo ))=20 (pk 'keyword foo)) An ambiguous case: (f #:foo 1). This matches both the first and second impl= ementation. is more specific that , so this sounds like t= he first method should win. But, =E2=80=98#:foo=E2=80=99 is more specific t= han , so the second should win. I don=E2=80=99t know what the rule is for positional arguments (I assume ea= rlier arguments are more important in case of ambiguity?). However, the sam= e rule cannot be applied to keyword arguments, since they aren=E2=80=99t po= sitional. Consider: (define-method (g (#:key foo ) (#:key bar )) (pk 'integer foo)) (define-method (g (#:key bar ) (#:key foo )) (pk 'symbol bar)) (g #:foo 1 #:bar a) ;integer or symbol? (g #:bar a #:foo 1) ;does this produce the same result? Either =E2=80=98integer=E2=80=99 or =E2=80=98symbol=E2=80=99 would be appro= priate, but it shouldn=E2=80=99t depend on whether #:foo or #:bar is writte= n first in the argument call. Now #:foo and #:bar need to be (ideally deter= ministically) ordered, but any particular ordering is somewhat arbitrary, a= nd it=E2=80=99s a bit against the notion of keyword arguments =E2=80=93 ord= erings are more a thing for _positional_ arguments. Potential escape: in case of ambiguity, give up and throw some kind of exce= ption. Not ideal, but at least it=E2=80=99s not random, doesn=E2=80=99t dep= end on how the keyword arguments were worded, and it would be limited to ke= yword methods. Best regards, Maime Devos