From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zelphir Kaltstahl Newsgroups: gmane.lisp.guile.user Subject: Macro id-memv??, workings of tripple dot Date: Fri, 15 Mar 2024 01:19:42 +0000 Message-ID: <16d24ba3-8a75-4589-a687-cfce981c92f2@posteo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26309"; mail-complaints-to="usenet@ciao.gmane.io" To: Guile User Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Fri Mar 15 02:20:39 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 1rkwFS-0006dc-C1 for guile-user@m.gmane-mx.org; Fri, 15 Mar 2024 02:20:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkwEo-0005C7-0y; Thu, 14 Mar 2024 21:19:58 -0400 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 1rkwEm-0005Ba-1q for guile-user@gnu.org; Thu, 14 Mar 2024 21:19:56 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkwEf-0001aw-9z for guile-user@gnu.org; Thu, 14 Mar 2024 21:19:55 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id AA046240027 for ; Fri, 15 Mar 2024 02:19:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1710465585; bh=xi9KGN5dsiq9Xt9kKXSk40Gq9sNvozpoBjjRdEIFP6M=; h=Content-Type:Message-ID:Date:MIME-Version:To:From:Subject:From; b=EGCtrPc+IP/WKa/AAT5ONnf9yjGocJxxWozh/BLOGq8DmxbcxyIGghuxvtuj7+FXd W1o4rH8TnCxBKc76qqvFTj7w7GhGUMYcDa3nS8Q7IvbI60DsUVPeGl6k8vPc5dNyIO guxjoXvgF0xa/iEu7xlbsFV2GeNXWZzOork/C1zwzl3yoerqlRnJvjjnI6jgiH71Us GLNU+FJBRRH51rEtGsK2f4BDe8z7NaZeJ5BBztWC6JRJgUKaPT63pepUGaL/iZxDfD pbdyROJtLIr6xIKxTDmIRKpYmJDxN3aSs2W5ko/CIhWRblszxv+37/U5RhcGOma746 fpPLX3Tak93LA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Twmcw6lF6z9rxG for ; Fri, 15 Mar 2024 02:19:44 +0100 (CET) Content-Language: en-US Received-SPF: pass client-ip=185.67.36.65; envelope-from=zelphirkaltstahl@posteo.de; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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:19467 Archived-At: Hello Guile Users, I have another macro understanding question and I think I don't yet grasp all the usages of the ellipsis/tripple dot/... : Again it is a macro from https://okmij.org/ftp/Scheme/assert-syntax-rule.txt. This time the id-memv macro, which I think I mostly understand, but have questions about: ~~~~ ;; A macro-expand-time memv function for identifiers ;; id-memv?? FORM (ID ...) KT KF ;; FORM is an arbitrary form or datum, ID is an identifier. ;; The macro expands into KT if FORM is an identifier, which occurs ;; in the list of identifiers supplied by the second argument. ;; All the identifiers in that list must be unique. ;; Otherwise, id-memv?? expands to KF. ;; Two identifiers match if both refer to the same binding occurrence, or ;; (both are undefined and have the same spelling). (define-syntax id-memv?? (syntax-rules () ((id-memv?? form (id ...) kt kf) (let-syntax ((test ;; Putting the ID matched in the outer syntax-rules ;; form, where it is flexible to stand for any ;; identifier, into the literals list makes it so, ;; that whatever was matched in the outer ;; syntax-rules is now literally matched against in ;; the inner syntax-rules. (syntax-rules (id ...) ;; If indeed FORM is the same identifier as ID, ;; then the result is the continuation for the ;; true case. ((test id _kt _kf) _kt) ... ((test otherwise _kt _kf) _kf)))) ;; Pass the form to be checked to test. (test form kt kf))))) ~~~~ My question is: Do the ... in the case ((test id _kt _kf) _kt) ... produce one case for each identifier in the list? I am guessing that this is what they do. However, they are mentioned as literals in the inner syntax-rules, so I was thinking the expansion will simply put literally three dots there, instead of understanding the three dots to mean "for each of the ids". And also I still am unsure about whether the three dots work like this at all. When one puts the ... after a compound expression, that contains the thing, that the ... were after in the matching -- in this case they were after id, and id is contained in the compound expression (test id _kt _kf) _kt) -- does that make the compound expression be generated for each thing matched? For example: (id-memv?? c (a b c) #t #f) would internally expand into the cases: ((test a _kt _kf) _kt) _kt) ((test b _kt _kf) _kt) _kt) ((test c _kt _kf) _kt) _kt) ((test otherwise _kt _kf) _kf) ? But if this is the case, then I might be misunderstanding the Guile docs at https://www.gnu.org/software/guile/manual/html_node/Syntax-Rules.html: "Instances of a pattern variable in the template must be followed by an ellipsis." So maybe I am just trying to see things here. Best regards, Zelphir repositories:https://notabug.org/ZelphirKaltstahl