From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Abou Samra Newsgroups: gmane.lisp.guile.user Subject: Re: error Wrong type to apply: # References: <36b686bbcedd978b99002f04709152660c2b3f7c.camel@abou-samra.fr> Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-r2Kgh+373bCJTdh2v3VI" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2535"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) To: Maxime Devos , Damien Mattei , guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Aug 09 01:01:33 2023 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 1qTVhl-0000Tx-1x for guile-user@m.gmane-mx.org; Wed, 09 Aug 2023 01:01:33 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTVhD-0007Jc-HU; Tue, 08 Aug 2023 19:00:59 -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 1qTVh1-0007Il-1E for guile-user@gnu.org; Tue, 08 Aug 2023 19:00:57 -0400 Original-Received: from mout.kundenserver.de ([212.227.17.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qTVgx-000074-Hp for guile-user@gnu.org; Tue, 08 Aug 2023 19:00:46 -0400 Original-Received: from [172.20.10.5] ([37.169.48.251]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.184]) with ESMTPSA (Nemesis) id 1MbBQU-1pwMnf2WPA-00bbXo; Wed, 09 Aug 2023 01:00:39 +0200 In-Reply-To: X-Provags-ID: V03:K1:p7tvDQ+1AEpu9hgWkl4l+rKZ8aQBkDbXIXq7vFclM93VRQWP05v 79KfL9xynkbuv63l6goFunPe7+o2QT0hoAK03EsCzxgl0NU1SyFe2wNdb6CRrTHVnNNiA01 SHihm4Ug+kwZoX0Gx+yzoi3koG4TnQeBOr99CXzvyjOujmeLg+W/U2TbeIviEReOVRWMyFt L8gerGAonVXxNVPv6T0FA== UI-OutboundReport: notjunk:1;M01:P0:aqgeAq3mWh8=;SGcKczg5f5mf73icPLOVysO/GnG 3kd11Zy1b4P7t5q2cFZbT7HvvaB/zJrZNKAAB8JawAO93mYsPeA74kRuastcqcsn9pRYnYFUN yTsd50Dm8obmZT0nv82U9ha7dt3RrzPHzdqKqPntMnPqWirqL3Fiw2QmvAWLmpDosZMWor2uQ lbe0oY1kYYqa0Harjz7MT4ZP26dLldFpIXmyUylqcdUZrim96laC1QdGDqVZDPftbo3EKiXqB YzUzukZ6W+pojgPBOTIOOsSNmhWdd3oS+bcR0zFHstfwunQjOUNQD9Jjc/omLj0QgvpAjiRBB ioc0fPVZ9FF28XdYJFWBGwNrefRaaDTJL8amF/OeDxFhaF0XrAtYaBd/lYRsvlcKyAp+C3tYk iYObD5bi4tW3jSELMtHXEhtxBsGv73fHjrI716bdzMT6QdYRnvfaGZK3ifsee33ZvNOhyBhfz 985cLo4GHhk/5tBKoYB34H9nJ/w44blLkF7OpexCP/Wza2vjLjg+1nj32dg7bKN5azZVTGY3h yk4tkjtFMD4o2SamlhcNxhV9FdqkRhS8QJVRIvUi3DcfYk0mbchcEO1h+XfifBmABJSU4xvQz 7bpJth3BWTG7sCcSoXhSWXDXvpcNK8CUkR04UIwPU6lWKx0LRUuhDMrQQ/fsJq8U+GYgUI3eW nSswKt0wRLaymAz88QAFTFqXcwioWBWlgI+eoy7jbUWlumGHWCnKsa+ysa3MBMtetfNGz0HZz lcyXBc7P6kyAScBQuZJ5BIDS+cNVLSLUNng5nLYtnT4qvAfbqOfAVLIbk9bh6qp0nP7TjRVB Received-SPF: pass client-ip=212.227.17.10; envelope-from=jean@abou-samra.fr; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19133 Archived-At: --=-r2Kgh+373bCJTdh2v3VI Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le mardi 08 ao=C3=BBt 2023 =C3=A0 21:38 +0200, Maxime Devos a =C3=A9crit=C2= =A0: > As such, this not working on the top-level seems a bug to me -- after=20 > all, a module definition is conceptually just a big let: >=20 > (if applicable) > (let () > =C2=A0=C2=A0 > =C2=A0=C2=A0 (define ...) > =C2=A0=C2=A0 (define-syntax-rule ...) ... > =C2=A0=C2=A0 ;; use a new macro using syntax-local-binding > =C2=A0=C2=A0 ;; to extract the syntax transformer (*). > =C2=A0=C2=A0 ) >=20 > (*) not sure if that precise approach actually works in this context This is very tempting to believe, and I wish it were true, but it's not tru= e. At least in Guile, the part doesn't happen at the end of evaluating the module. Each module variable is created and inserted while evaluating the define form. Otherwise this would give an error: (define a 5) (define b (module-ref (current-module) 'a)) (display b) The consequences are not innocent. A variable is associated to a binding which is a "place" in the terminology of some other languages, i.e., something you can set!. For toplevel variabl= es, because you can use module-set!, a module variable is used as the place. And because module variables are bound to names which are just symbols, duplicate definitions stomp on each other. Consider this: (define a 5) (define (b) a) (define a 6) (display (b)) This is valid in Guile and prints 6. The second definition for `a` reuses the same variable as the first one, effectively acting like a set!. Contrast this with (let () (define a 5) (define (b) a) (define a 6) (display (b))) which raises an error due to the duplicate binding. As https://okmij.org/ftp/Scheme/macros.html#syntax-rule-dark-corner puts it, "the top level of Scheme is indeed under-specified and treacherous= ". Best, Jean --=-r2Kgh+373bCJTdh2v3VI Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSZ7TKxnKGyBvBjzBmj8PYLiTOX/gUCZNLJFQAKCRCj8PYLiTOX /gkKAPwOyj0qIA6xM6HymAKTE0qWl3ZTEtLLbJ+V6d9bz4rS1wEAkm2ntnKQJGOu uU7CPCyzjIv0cZGfeTK4V0reA3Cnvgc= =vKEG -----END PGP SIGNATURE----- --=-r2Kgh+373bCJTdh2v3VI--