From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id WBa0Ms9nP2JMdAEAgWs5BA (envelope-from ) for ; Sat, 26 Mar 2022 20:21:51 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id kN83K89nP2IvSAAAG6o9tA (envelope-from ) for ; Sat, 26 Mar 2022 20:21:51 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 179DB3A7A7 for ; Sat, 26 Mar 2022 20:21:51 +0100 (CET) Received: from localhost ([::1]:40164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYByw-0002Ll-7C for larch@yhetil.org; Sat, 26 Mar 2022 15:21:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYByR-0001zV-MQ for guix-devel@gnu.org; Sat, 26 Mar 2022 15:21:19 -0400 Received: from [2a02:1800:120:4::f00:14] (port=37170 helo=xavier.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 1nYByP-00064W-3c for guix-devel@gnu.org; Sat, 26 Mar 2022 15:21:19 -0400 Received: from [172.20.10.5] ([213.119.168.171]) by xavier.telenet-ops.be with bizsmtp id B7MB270093iD4dh017MCWY; Sat, 26 Mar 2022 20:21:12 +0100 Message-ID: Subject: A lexical use-modules? From: Maxime Devos To: guile-devel@gnu.org, guix-devel@gnu.org Date: Sat, 26 Mar 2022 20:21:07 +0100 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-qalLeVX3MuqOVsKi+GvW" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1648322472; bh=+FpZqnXXQClWuoISV/8+5lohrZEqBs5/KpZze7zQOh0=; h=Subject:From:To:Date; b=aVWLjI3g0G0+cNOjNFqgEqo8LaKpEhYfNN3hLiatFeDv1L9WEhA4iOsDOqB7Q8STG rWLRA9c+65lm1cNUTILQZTwR0LuO5gH4DJx5Tx0nbHOV0JGf3dPEWl00CGahMTsIU4 vfnQYPZgoK34xfFefQ8K1NAhsJvIyc/LXffy+Tz6DmyIwWzmtoyMEmZWg222oToDsS wLx6+gOunPyo8TrRHcdN1rDVDCTIwFwhlUBdE+xkTj4BCYlII0g9K/Nhasc+nYj6P5 IZsibRa8G8jGg6QySUQSw/XLU3hI36SbpXfTh8VnfcBNSJtL9/EeLxs0Gqm7nh54fi dBumSS+k0u9pg== X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a02:1800:120:4::f00:14 (failed) Received-SPF: pass client-ip=2a02:1800:120:4::f00:14; envelope-from=maximedevos@telenet.be; helo=xavier.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: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1648322511; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=+FpZqnXXQClWuoISV/8+5lohrZEqBs5/KpZze7zQOh0=; b=hsN21HgP42YOn4fFX6BN94kSgwj3LQGXxLOLttYQO3QunyGJWJiKOjGmM7tGNOlxOJNIm7 GTK6axC68DwxTnvwy9BgcjcM4k8rTlz3DgsG7Ji+Oaa+JgNvlK/YsZzLOJGVbNK6iEMgPM yhpnLO444YK3Rrq5zF4u/5ZOJW+QAdftPPbptlYbDS5HZ/GwVhB42NyAfbeStbJY8bVz2p +oqMcRTXaSgrYx6kptGRiLxZ8bC5q+QVW71iUT0B1PXcRP0B7OUd4qVk/ZnBudddO3J+R/ /zeRO0ukdUHIJlw3KL6nz2cwugL620VzEAnNhY2b7/9QMbr59IRh1vVkDT7cJQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1648322511; a=rsa-sha256; cv=none; b=Rkpv9/na9gLJ5PT37eEuOP/+UAUi90fbxDlK9GTyQ9ZS3fsNxEvXjQ0bfS6ncTCewakwX1 45vEhcIMjw0p0/7z65x/ogjsfWHeqcbtGs1YTUH/XURgOCUsCdZ6FF2BCRwVR91i2DlXkD VLrIaBCIv1oVdJuvRNW+DOiKY5wz70FCssxrdCb5G9noirUAIHK42iVp7GoJevS+/Fpg7X 1ugdIIGmNdWOWyqL2kHZi3oVIOzO2xwNXWmmsoxYQywcFUnReQ5j0vOlrulOi9UB4bGaB5 x43DWdhMMhaqJYz5EcAWsl13DW0vJ+QzFjLDmZNgtJD/E0phPZhCweuBGMmjPg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=telenet.be header.s=r22 header.b=aVWLjI3g; dmarc=pass (policy=none) header.from=telenet.be; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -5.28 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=telenet.be header.s=r22 header.b=aVWLjI3g; dmarc=pass (policy=none) header.from=telenet.be; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 179DB3A7A7 X-Spam-Score: -5.28 X-Migadu-Scanner: scn1.migadu.com X-TUID: L1VaTIBhwSg0 --=-qalLeVX3MuqOVsKi+GvW Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, [ CC'ing guix-devel@ because this functionality could be useful in Guix package definitions ] Currently, use-modules cannot be meaningfully used inside procedures, unless '(current-module)' is always the module in which the procedure is defined. I wondered if some kind of 'lexical use-modules' was possible, with sufficient macroology and module reflection, and it looks like it is: (use-modules (srfi srfi-1)) (define-syntax use-module/lexical ;; todo: integrate into (use-modules ...)? (lambda (s) (syntax-case s () ((_ foo) (let* ((module-name (syntax->datum #'foo)) (interface (resolve-interface module-name))) (define (binding->import name variable) (define name-syntax (datum->syntax s name)) #`(define-syntax #,name-syntax (identifier-syntax (@ foo #,(datum->syntax #'irrelevant name))))) #`(begin #,@(module-map binding->import interface))))))) (define &exception 'top-level) (let () (use-module/lexical (ice-9 exceptions)) (pk 'inner &exception raise-continuable)) ;;; (inner # #) (pk 'outer &exception) ;;; (outer top-level) (pk 'unbound-variable raise-continuable) ;; a backtrace! Limitation: things like (define (foo) (use-module/lexical (platform-specific-constants)) (if on-linux? CONSTANT_ONLY_DEFINED_ON_LINUX CONSTANT_ONLY_DEFINED_ON_HURD)) won't work in cross-compilation contexts. Greetings, Maxime. --=-qalLeVX3MuqOVsKi+GvW 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+4iGRcl7gUCYj9noxccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7pG+AP4vhC6duf6MMWr1/AebTP92dVSt KYqjkeAaqgyjepEnXgD/QwCFJGnnZQk3Ow2hirfV8WOQAlbdV3aRipBd/mhCIgM= =1yFl -----END PGP SIGNATURE----- --=-qalLeVX3MuqOVsKi+GvW--