From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damien Mattei Newsgroups: gmane.lisp.guile.user Subject: Re: with-syntax return error in Guile, not in Kawa or Racket Date: Mon, 6 May 2024 23:34:53 +0200 Message-ID: References: <8a27bbf6579a8f3676ee16ad70afca2efbec2686.camel@abou-samra.fr> <20240506205840.Kuyd2C00E17cfcj01uyfo5@xavier.telenet-ops.be> 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="17548"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Jean Abou Samra , guile-user To: Maxime Devos Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Mon May 06 23:36:08 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 1s460G-0004L9-9I for guile-user@m.gmane-mx.org; Mon, 06 May 2024 23:36:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s45zd-0003hg-UI; Mon, 06 May 2024 17:35:31 -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 1s45zL-0003ee-Ei for guile-user@gnu.org; Mon, 06 May 2024 17:35:19 -0400 Original-Received: from mail-qv1-xf33.google.com ([2607:f8b0:4864:20::f33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s45zH-0001Xr-4O for guile-user@gnu.org; Mon, 06 May 2024 17:35:11 -0400 Original-Received: by mail-qv1-xf33.google.com with SMTP id 6a1803df08f44-69cb4a046dfso7696776d6.2 for ; Mon, 06 May 2024 14:35:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715031305; x=1715636105; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=CF1cpGhB4mXemFOrp3egHiBiXLGMHziGZ4KwQujn/+s=; b=N9KX0qb4FwpFIzyiHNgBwXn9ysVU/6cgCxSvpU8AUFtjlNodVHE5FLtxqcWn1vweNY iE2JFUgBiPBHy18/byqj5hyuPDjEVsUHucGL05NQXgeE4GdzMcbNWG6n7xsInuMXG+Gs gs7UE3XM+fnJP7lafZ9RZ/oEbc4c6wdtVo0ZmBuE5MXS1H/0GJ3awXCQBlnGnOqRauUb KLM5pLjLl7pW+kZfzHvFgzpjQDiHKP6VJixhdhPUv0kG7B7DPWCvZxRNCdiXp6biYfoG xiN52Y29yhIwoYy1R+qO9Iw841Sn5KfCGrRghwBydLS2v/0J+F57dLO9+d+Bqs0+P+TH U81g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715031305; x=1715636105; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CF1cpGhB4mXemFOrp3egHiBiXLGMHziGZ4KwQujn/+s=; b=qCC3lQrHPwuZzJevYcM5iD7lHd01R9IjIEX4xmW/84T4+Dkj5YcC1LOeFqBaLFGAp6 iM+ZWzAy4q8YD555hWzf75g98+sJ17gGFdvlnPvVFGUJLsZVeQAdrXHSK5Kz4m1YasW+ 7wmt8cQHTf63x23psrWuCEslpptzgPYD07FfjzgUOBjxm8MchNZ+/YDC6CynpHi/MNy+ laT3UBPqRGfMJuf4RpR+Dj8fE51NMEc596Ln6D0IQVTw0rjR2VV+CdMvMXEgXdNWwJSP UU9iMatVWE9mV4sj03Tsb9a45lTLKtA1Ozbs031tP6PtyFT6t4r2P2yVqJzo95r7fh6/ YzRw== X-Forwarded-Encrypted: i=1; AJvYcCVlVAWFUzNEB9L8P4MJl2GvWcNhh8nyfAnYtSBnOy8ymfG13mJMNgjFRFO1H03EB9SoCYJgOaXJYRuHCsv28AaMaG4= X-Gm-Message-State: AOJu0Yx2AUzSogAxe7eWpbtoPLHWWfcnnwY2n5Zf6Yay9mGCt3wj1+EA qzoVFIduj/Rs8pMG67byJv7ZKi58QOTfBuNUb7XkWE5nmkdw3wRz8AZhcRchUCYtLTzBSQGeEfj i3IOhI38WTRtcK+Te/RUzVUacLFU= X-Google-Smtp-Source: AGHT+IGyxvlLlHpewKz3ufSih0Bnj/xZqOc00pGpgmtQcTTmHefzuxTsPHWBn3ukxb5EoGduor4s5QgQakmaiRdO/xQ= X-Received: by 2002:ad4:5f49:0:b0:6a0:936e:4f93 with SMTP id p9-20020ad45f49000000b006a0936e4f93mr14020144qvg.60.1715031305437; Mon, 06 May 2024 14:35:05 -0700 (PDT) In-Reply-To: <20240506205840.Kuyd2C00E17cfcj01uyfo5@xavier.telenet-ops.be> Received-SPF: pass client-ip=2607:f8b0:4864:20::f33; envelope-from=damien.mattei@gmail.com; helo=mail-qv1-xf33.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_FONT_LOW_CONTRAST=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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:19602 Archived-At: not sure to understand, i admit i'm testing new things for me , i try to understand macro syntax and all the stuff... reading https://www.greghendershott.com/fear-of-macros/index.html but half (or less) the way..... do you mean just replacing 'list by #'list ? i do it and it is still working at least: (define-syntax $bracket-apply$ (lambda (stx) (syntax-case stx () ;; a version that pre-compil the infix expression, should be faster;; scheme@(guile-user)> {#(1 2 3 4 5 6 7 8 9)[6 - 4 : 5 + 2]};; $bracket-apply$ : parsed-evaluated-args=3D#;; $1 =3D #(3 4 5 6 7);; scheme@(guile-user)> (define i 5);; scheme@(guile-user)> {#(1 2 3 4 5 6 7 8 9)[6 - 4 : i + 2]};; $bracket-apply$ : parsed-evaluated-args=3D#;; $2 =3D #(3 4 5 6 7) (($bracket-apply$ container . args-brackets) (with-syntax ((parsed-evaluated-args (datum->syntax stx ; #f (cons #'list (optimizer-parse-square-brackets-arguments-lister (syntax->datum #'args-brackets)))))) ;;(display "$bracket-apply$ : parsed-evaluated-args=3D") (display #'parsed-evaluated-args) (newline) =09 #'($bracket-apply$next4list-args container parsed-evaluated-args)))))= ) another strange thing perheaps related to macro is that the compile warns me always that the optimizer-parse-square-brackets-arguments-lister procedure is not found: GNU Guile 3.0.8.99-f3ea8 Copyright (C) 1995-2022 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> (use-modules (Scheme+)) ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=3D0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /usr/local/share/guile/site/3.0/Scheme+.scm ;;; note: source file /usr/local/share/guile/site/3.0/for_next_step.scm ;;; newer than compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3= .0/for_next_step.scm.go ;;; compiling /usr/local/share/guile/site/3.0/for_next_step.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3= .0/for_next_step.scm.go ;;; note: source file /usr/local/share/guile/site/3.0/growable-vector.scm ;;; newer than compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3= .0/growable-vector.scm.go ;;; compiling /usr/local/share/guile/site/3.0/growable-vector.scm ;;; growable-vector.scm:149:2: warning: possibly wrong number of arguments to `vector-copy' ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3= .0/growable-vector.scm.go ;;; note: source file /usr/local/share/guile/site/3.0/infix-operators.scm ;;; newer than compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3= .0/infix-operators.scm.go ;;; compiling /usr/local/share/guile/site/3.0/infix-operators.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3= .0/infix-operators.scm.go ;;; note: source file /usr/local/share/guile/site/3.0/overload.scm ;;; newer than compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3= .0/overload.scm.go ;;; compiling /usr/local/share/guile/site/3.0/overload.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3= .0/overload.scm.go ;;; note: source file /usr/local/share/guile/site/3.0/array.scm ;;; newer than compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3= .0/array.scm.go ;;; compiling /usr/local/share/guile/site/3.0/array.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3= .0/array.scm.go ;;; WARNING: compilation of /usr/local/share/guile/site/3.0/Scheme+.scm failed: ;;; *Unbound variable: optimizer-parse-square-brackets-arguments-lister* scheme@(guile-user)> {v <+ (vector 1 2 3 4)} scheme@(guile-user)> {v[1 : 3] <- #(-1 -2 -3 -4 -5 -6 -7)[2 : 4]} scheme@(guile-user)> v $1 =3D #(1 -3 -4 4) but anyway it works =F0=9F=A4=94 On Mon, May 6, 2024 at 8:58=E2=80=AFPM Maxime Devos wrote: > > [...] > > > > > > That should work, but it's also non-hygienic. For example, it will > > > be affected if the user does > > > > > > (let ((list ...)) > > > (call-your-macro ...)) > > > > > >> and since you use #f in the datum->syntax call, it will also strip awa= y > > >> all hygiene annotations from the args-brackets, causing problems insid= e > > >> that as well. > > >> > > > > >i changed #f to stx in the macro > > > > That doesn=E2=80=99t make it hygienic, for the reasons mentioned above. > > > > syntax (#') / quasisyntax (#`)/ unsyntax (#,) and unsyntax-splicing (#,@= ) > your friend =E2=80=93 they behave pretty much the same as their > quote/quasiquote/... counterparts. > > > > Hygiene is usually pretty simple =E2=80=93 just don=E2=80=99t do sexp thi= ngs (say, > quasiquote), do syntax things (quasisyntax) instead, then typically thing= s > will go well. > > > > Best regards, > > Maxime Devos. >