From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Newsgroups: gmane.lisp.guile.user Subject: Re: Syntax objects as traditional pairs Date: Tue, 05 Apr 2022 20:23:23 +0200 Message-ID: <0aa524c1-29b8-42ca-946a-6468ac6e6db4@www.fastmail.com> References: <1024dc44-d9f2-80b5-4b26-01a3779052ee@abou-samra.fr> 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="20742"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.7.0-alpha0-385-g3a17909f9e-fm-20220404.001-g3a17909f To: "Jean Abou Samra" , guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Tue Apr 05 20:24:18 2022 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 1nbnqi-00058D-Je for guile-user@m.gmane-mx.org; Tue, 05 Apr 2022 20:24:18 +0200 Original-Received: from localhost ([::1]:57602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nbnqh-0001QX-9Z for guile-user@m.gmane-mx.org; Tue, 05 Apr 2022 14:24:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nbnqO-0001QL-5w for guile-user@gnu.org; Tue, 05 Apr 2022 14:23:57 -0400 Original-Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:59107) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nbnqM-0002jl-0m for guile-user@gnu.org; Tue, 05 Apr 2022 14:23:55 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id A812E3201DDC; Tue, 5 Apr 2022 14:23:48 -0400 (EDT) Original-Received: from imap51 ([10.202.2.101]) by compute4.internal (MEProxy); Tue, 05 Apr 2022 14:23:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.se; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; bh=eKAMK3cLyzl1g1 ZhQgeIB0pb+kaVXRYyHLNIY7BemsU=; b=koCI1oboiFuhbCCoifXa/7GwxD1+HG QPtG/VVTdc0rOi5xqUZr1M84j4EKWMRfjNA/ynN8lF5VPB1/EeB0MpomrOxNxYBY 6/Q1vJkxUGnWlFW0IPSFGmNjcHdPcaIAXw6VPsPYStCUq24sAr2MzgtFX6VQ0hww zuSRWSj78nW2lwthAm2XiOKGeACgUc6LM53cJCdb4/BXVnv4aU92Z+3csk8QwQRG 6wt7pz3I+Z3lANhLeOw9mReb8/kozkasHktVsvKcOCmVIFukiGYnqRMczAbFNLAP WjdTT6zmHaL0d+2EZFk3nEaX+KBIX+Vmdo3ZSlhsUUz1W8RiT0Q88ygA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=eKAMK3cLyzl1g1ZhQgeIB0pb+kaVXRYyHLNIY7BemsU=; b=k51bQv7D G7dLXDdT09Bs4xmOJ7KxVVmHBvAOPF7Go0joSFiLsBkFuiJS2nqQAKT5yVsI/9jK OeCp+DnMNmqe92qCSy7k6m/YwIbc9OPklwEnHzjWOmEPtDizpfNVPhbaiJFfa7wF of1DVNxmWif6sJP/aX9FRT0tOpix1cVfal+FqvEMz94AnAmO4pPHRBm7u/rMomYP 9+hLnyQQEB73FsDBXTmjukIGSTQf/eM7GuXo/0T82PV58zxUb5X0CruqvFQpjGTT s4jG/AXdR0NG61aJ2JBzdOgKorAzqB1r557JzFWFdj3m96V31+fDfTiJ0+1v7JCr YMtaZB0+8N7yMw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudejgedguddvtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepnfhi nhhushgpuehjnphrnhhsthgrmhcuoehlihhnuhhsrdhinhhtvghrnhgvthesfhgrshhtmh grihhlrdhsvgeqnecuggftrfgrthhtvghrnhepkeelveeiveeljeffteeiledtleekveet udehfeehudeifffftddtgeejieehtdejnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheplhhinhhushdrihhnthgvrhhnvghtsehfrghsthhmrghi lhdrshgv X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 1157AB60062; Tue, 5 Apr 2022 14:23:47 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <1024dc44-d9f2-80b5-4b26-01a3779052ee@abou-samra.fr> Received-SPF: pass client-ip=64.147.123.21; envelope-from=linus.internet@fastmail.se; helo=wout5-smtp.messagingengine.com 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.lisp.guile.user:18230 Archived-At: Because both syntax objects encapsulating a list and a list of syntax ob= jects are valid syntax objects. If you match a list using just a pattern var it will be a syntax objects= . I'd you match it using (pattern ...) you will do #'(pattern ...) and g= et a list. You can easily implement syntax->list that handles both cases and always= returns a list. --=20 Linus Bj=C3=B6rnstam On Tue, 5 Apr 2022, at 01:00, Jean Abou Samra wrote: > Hi, > > I am lost as to when a syntax object whose syntax->datum is a pair > can be manipulated as a plain Scheme pair. For example: > > > (define synt1 #'(a b)) > (pk 'syntax synt1 'pair? (pair? synt1)) > (pk 'car (car synt1)) > > (define-syntax mysyntax > =C2=A0 (lambda (stax) > =C2=A0=C2=A0=C2=A0 (syntax-case stax () > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((_ thing) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (begin > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (pk 'syntax #'thing = 'pair? (pair? #'thing)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (pk 'car (car #'thin= g))))))) > > (mysyntax (c d)) > > > results in > > > ;;; (syntax (# #) pair? #t) > > ;;; (car #) > > ;;; (syntax # pair? #f) > Backtrace: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 7 (primi= tive-load "/home/jean/repos/lilypond/build/test.s=E2=80=A6") > In ice-9/eval.scm: > =C2=A0=C2=A0 721:20=C2=A0 6 (primitive-eval (mysyntax (c d))) > In ice-9/psyntax.scm: > =C2=A0 1229:36=C2=A0 5 (expand-top-sequence (#) =E2=80=A6) > =C2=A0 1121:20=C2=A0 4 (parse _ (("placeholder" placeholder)) ((top) = #(# # =E2=80=A6)) =E2=80=A6) > =C2=A0 1342:32=C2=A0 3 (syntax-type (mysyntax #) # =E2=80=A6) > =C2=A0 1562:32=C2=A0 2 (expand-macro # =E2=80=A6) > In ice-9/eval.scm: > =C2=A0=C2=A0=C2=A0 159:9=C2=A0 1 (_ #(#(#) #)) > =C2=A0=C2=A0=C2=A0 155:9=C2=A0 0 (_ _) > > ice-9/eval.scm:155:9: In procedure car: Wrong type argument in positio= n=20 > 1 (expecting pair): # > > > Why does one syntax object look like a pair and not the other? > What is the difference between the two cases? > > Thanks, > Jean