From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxime Devos Newsgroups: gmane.lisp.guile.devel Subject: Re: A lexical use-modules? Date: Sun, 27 Mar 2022 12:40:03 +0200 Message-ID: References: <4fb1eef748667d5e33d9df674af77ff52d30cd00.camel@telenet.be> Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-sYWZQ+UhS+OiITGBsxM9" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34107"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.38.3-1 Cc: guile-devel@gnu.org To: Stefan Israelsson Tampe Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Mar 27 12:40:41 2022 Return-path: Envelope-to: guile-devel@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 1nYQK9-0008gv-DF for guile-devel@m.gmane-mx.org; Sun, 27 Mar 2022 12:40:41 +0200 Original-Received: from localhost ([::1]:36400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYQK8-0000p2-02 for guile-devel@m.gmane-mx.org; Sun, 27 Mar 2022 06:40:40 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:54862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYQJj-0000ou-PF for guile-devel@gnu.org; Sun, 27 Mar 2022 06:40:15 -0400 Original-Received: from [2a02:1800:120:4::f00:13] (port=53002 helo=baptiste.telenet-ops.be) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYQJh-0003DV-Ai for guile-devel@gnu.org; Sun, 27 Mar 2022 06:40:15 -0400 Original-Received: from [172.20.10.9] ([213.251.125.53]) by baptiste.telenet-ops.be with bizsmtp id BNg72700Y19ErMx01Ng8Y3; Sun, 27 Mar 2022 12:40:08 +0200 In-Reply-To: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1648377608; bh=IMeLhm7pDcX6hUbCLlr4f/HBGk0puUxR26zgDJjLsow=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=kK3q4LrskOqunWeiwIt6ZHWdKIBcYMa5s1mweDBUzDqnGXxW+UiDGb2PcfNAA0R8d WQiFA4n8gQhxdxg2KNxNbm4b6btI2zbCHv8g0Tl4Vy1zKaWSwLaPJFQrSwIMJ81VWl C2/I8rqtHCh0psggGwSbPNfOmG0I/Xs/DwI7IWC6XGDbZxN0nmXLKKVMKKuJbdIlRS rx49mNBpfQwydMLrpXyKxEs2XLLI3G0SKd7n0NAeUHtFHjiClexZtmCvF8bM6Z7lwm bGB5/3sUtIMjutA8UdY+afh+0BVGuhlFSeKXf4XAI6jRf2lvx6m3uCFHDT0blyBrvf wJmmup0fF0xPA== X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a02:1800:120:4::f00:13 (failed) Received-SPF: pass client-ip=2a02:1800:120:4::f00:13; envelope-from=maximedevos@telenet.be; helo=baptiste.telenet-ops.be X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:21178 Archived-At: --=-sYWZQ+UhS+OiITGBsxM9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Stefan Israelsson Tampe schreef op zo 27-03-2022 om 11:53 [+0200]: Hmm actually you only have lexical macros that reference module variables. That is not lexical variables which have more optimisation associated with it at least used to. But is better speedwise than the hash lookups I suggested. Anyhow you can create a let with local variables and set them from the module dynamically. Maybe wingos recent work mean that your approach is best. Would be interesting to do some tests to see.=C2=A0 Optimisations are performed at expansion time: (macroexpand #'(let () (use-module/lexical (ice-9 exceptions)) (do-stuff))) ;; the unused imports disappeared! $6 =3D #=20 A variable is only dereferenced when it is used: ,optimize (let () (use-module/lexical (ice-9 exceptions)) (lambda () raise-continuable)) $7 =3D (lambda () (@ (ice-9 exceptions) raise-continuable)) So lexical imports should be as fast as directly writing (@ (foo) bar). I don't see how creating new modules at runtime and using 'module-ref' could make things faster (*) here, given that it just seems like an extra layer of indirection and it probably prevents things like inlining. (*) I'm only counting runtime here, not compilation time. Greetings, Maxime. --=-sYWZQ+UhS+OiITGBsxM9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYkA/AxccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7tNxAQCvl7Ki1CbpCKHgaiYxrgWsr7SB QXb02BeLSfs5kTTi8AEA12MkSGs50grJ5ExTvGKSHKTHULyvrAN2prS+GT/2LgY= =r8Wp -----END PGP SIGNATURE----- --=-sYWZQ+UhS+OiITGBsxM9--