From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.user Subject: Re: primitive eval with module => Unbound variable? Date: Wed, 17 May 2017 21:44:02 +0200 Message-ID: <8737c3nu9p.fsf@pobox.com> References: <87ziec4g62.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1495050280 24345 195.159.176.226 (17 May 2017 19:44:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 17 May 2017 19:44:40 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: guile-user@gnu.org To: Jan Nieuwenhuizen Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed May 17 21:44:35 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dB4s7-0006C5-Ev for guile-user@m.gmane.org; Wed, 17 May 2017 21:44:35 +0200 Original-Received: from localhost ([::1]:50513 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB4sC-00005l-Nz for guile-user@m.gmane.org; Wed, 17 May 2017 15:44:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB4ro-00005W-Ep for guile-user@gnu.org; Wed, 17 May 2017 15:44:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB4rl-0002hu-89 for guile-user@gnu.org; Wed, 17 May 2017 15:44:16 -0400 Original-Received: from pb-sasl2.pobox.com ([64.147.108.67]:50085 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dB4rl-0002hb-2J; Wed, 17 May 2017 15:44:13 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id 5760482CAD; Wed, 17 May 2017 15:44:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=OaCB6JY58YnJ+fbPoIqDnlSd+Qg=; b=SclAOJ 613jZ0Y+fwKnCuWSysRmytwFt20CR2Id8Y0ZDiVRLgZbkCX4vIW8YZHc8uel4Z0A jWMvbFbzPm2Ll5389vPCIlh+n3lmXtkshaH2PNvtFsrRq8+mVTkHbgpkUJ4Pi6eO aqauDNBu/qFxVjJxk7TrVkb2auwGy7f1nFHyQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=YD3DKjP9CBD7CWgUBTUzuNioBl5V3Imt 7sUJmLqjOj491ENwpSPosWki9kTA1PSKJ6lzvLUjxSM1X23vbh1nnfOBa7A7yP0/ YO0VYpKi8srrSDJ6AlA7u70ulirGkeEkRyblzaiIHg6XqHH7qyBqCfKw+QJK38Vi vxuZhMFSwqU= Original-Received: from pb-sasl2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id 50B2982CAC; Wed, 17 May 2017 15:44:11 -0400 (EDT) Original-Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl2.pobox.com (Postfix) with ESMTPSA id 478A682CAB; Wed, 17 May 2017 15:44:10 -0400 (EDT) In-Reply-To: <87ziec4g62.fsf@gnu.org> (Jan Nieuwenhuizen's message of "Tue, 16 May 2017 23:59:01 +0200") X-Pobox-Relay-ID: 32A9C4DE-3B39-11E7-83F4-384B894C8D7C-02397024!pb-sasl2.pobox.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.108.67 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13724 Archived-At: On Tue 16 May 2017 23:59, Jan Nieuwenhuizen writes: > This code works when not put in a module; make it a module and I get > > => ERROR: Unbound variable: bar I assume you mean that this doesn't work: (define-module (foo) #:export (baz)) (define bar 42) (define (baz) (primitive-eval 'bar)) Then from another module you do (use-modules (foo)) and try to (baz). The thing is that primitive-eval evaluates its expression with respect to the current module. The current module when you do (use-modules (foo)) isn't (foo) -- it's the importing module. This is the right thing: (define-module (foo) #:export (baz)) (define eval-module (current-module) (define bar 42) (define (baz) (eval 'bar eval-module)) Cheers, Andy