From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Jan Nieuwenhuizen Newsgroups: gmane.lisp.guile.user Subject: primitive eval with module => Unbound variable? Date: Tue, 16 May 2017 23:59:01 +0200 Message-ID: <87ziec4g62.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1494971986 28652 195.159.176.226 (16 May 2017 21:59:46 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 16 May 2017 21:59:46 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue May 16 23:59:40 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 1dAkVI-0007Hc-Cp for guile-user@m.gmane.org; Tue, 16 May 2017 23:59:40 +0200 Original-Received: from localhost ([::1]:44311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAkVN-0008PM-QT for guile-user@m.gmane.org; Tue, 16 May 2017 17:59:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAkV1-0008PC-9G for guile-user@gnu.org; Tue, 16 May 2017 17:59:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAkV0-0003EI-6q for guile-user@gnu.org; Tue, 16 May 2017 17:59:23 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:46385) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAkUt-0003CZ-Qe; Tue, 16 May 2017 17:59:15 -0400 Original-Received: from peder.onsbrabantnet.nl ([88.159.206.46]:56360 helo=dundal.peder.onsbrabantnet.nl) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dAkUt-0007xK-88; Tue, 16 May 2017 17:59:15 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:13722 Archived-At: Hi! My Mescc C compiler produces from C int main () {return 0;} a list of functions (lambdas), that are called with text-address, data-address, globals, functions to produce lists of x86 instructions: # =3D> (85 137 229 131 236 64) # =3D> (184 0 0 0 0) # =3D> (80) # ... I hoped to instead produce intermediate results in a sexp that can be written to file (like .o object files). So instead of evaluating the lambdas, I tried quoting them to now produce =3D=3D> (lambda (f g ta t d) (list 85 137 229 131 236 64)) (lambda (f g ta t d) (list 184 0 0 0 0)) (lambda (f g ta t d) (list 80)) (lambda (f g ta t d) (i386:push-global-address (+ (data-offset "s:scaffo= ld/mesmes" g) d))) ... and primitive-eval and run them later.... However, when I do this, i386:push-global-address is an Unbound variable. Here's a small test that demonstrates my problem --8<---------------cut here---------------start------------->8--- ;; this works without define-module: ;; guile -e 'main' -s foo.scm ;; uncomment define-module below and run: ;; guile -e '(@ (foo) main)' -s foo.scm ;; =3D> ERROR: Unbound variable: bar ;; (define-module (foo) #:export (main)) (define (bar) (display "bar!!!\n")) (define foo '(lambda (x) (bar))) (define (main . rest) (let () (format (current-error-port) "eval: foo=3D~s\n" foo) (let ((x (primitive-eval foo))) (format (current-error-port) " =3D>~s\n" x) (x 0)))) --8<---------------cut here---------------end--------------->8--- This code works when not put in a module; make it a module and I get =3D> ERROR: Unbound variable: bar What should I be doing differently? Greetings, janneke --=20 Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.com