From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: Should an enclosing let keep the compiler from handling define-module? Date: Mon, 05 Aug 2019 14:04:04 -0400 Message-ID: <87tvav8p5c.fsf@netris.org> References: <875znrmp0p.fsf@trouble.defaultvalue.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="174847"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: guile-devel@gnu.org To: Rob Browning Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Aug 05 20:05:12 2019 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1huhM8-000jNe-CO for guile-devel@m.gmane.org; Mon, 05 Aug 2019 20:05:12 +0200 Original-Received: from localhost ([::1]:56372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huhM7-0002Jr-DG for guile-devel@m.gmane.org; Mon, 05 Aug 2019 14:05:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51401) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huhLK-0001ew-3o for guile-devel@gnu.org; Mon, 05 Aug 2019 14:04:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huhLH-0008Uc-D8 for guile-devel@gnu.org; Mon, 05 Aug 2019 14:04:21 -0400 Original-Received: from world.peace.net ([64.112.178.59]:60028) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1huhLG-0008U7-V1 for guile-devel@gnu.org; Mon, 05 Aug 2019 14:04:19 -0400 Original-Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1huhLE-0008Qs-BH; Mon, 05 Aug 2019 14:04:16 -0400 In-Reply-To: <875znrmp0p.fsf@trouble.defaultvalue.org> (Rob Browning's message of "Wed, 24 Jul 2019 10:27:18 -0500") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.112.178.59 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 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.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:20029 Archived-At: Hi Rob, Rob Browning writes: > This doesn't work with 2.2.4: > > (eval-when (expand load eval) > (let ((ignored #t)) > (define-module (bar) > #:use-module (has-foo)) > (format #t "foo: ~s\n" (foo)))) > > producing: > > ERROR: In procedure %resolve-variable: > Unbound variable: foo 'define-module' should only be used at top-level. Ideally, we should report a clearer error when it's used elsewhere. > Is that expected? I'm not sure if what I was attempting is reasonable, > but the original motivation was wanting to create a syntax that can > capture and restore some state around the invocation of define-module, > e.g.: > > (define-syntax def-mod > (lambda (x) > (syntax-case x () > ((_ name) > #`(eval-when (expand load eval) > (let ((orig (current-language))) > (current-language 'scheme) > (define-module name > #:use-module (has-foo)) > ... > (current-language orig))))))) It seems misguided to try to use Scheme code to temporarily switch the current language to Scheme. Doesn't this approach presuppose that Scheme is already the current language? To be honest, I'm not yet very familiar with how the 'current-language' parameter can be used, but from a quick search of the source, it seems clear that the finest granularity that it can possibly be expected to work on is that of a single top-level form. Can you help me understand what you are trying to accomplish here? Thanks, Mark