From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Rob Browning Newsgroups: gmane.lisp.guile.user Subject: Re: loading a module via an absolute path Date: Sat, 05 Oct 2002 20:51:56 -0500 Sender: guile-user-admin@gnu.org Message-ID: <87vg4gl4g3.fsf@raven.i.defaultvalue.org> References: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1033869375 14597 127.0.0.1 (6 Oct 2002 01:56:15 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 6 Oct 2002 01:56:15 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17y0eT-0003n9-00 for ; Sun, 06 Oct 2002 03:56:13 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17y0cu-0003TA-00; Sat, 05 Oct 2002 21:54:36 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17y0ax-00082f-00 for guile-user@gnu.org; Sat, 05 Oct 2002 21:52:35 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17y0al-0007Tr-00 for guile-user@gnu.org; Sat, 05 Oct 2002 21:52:29 -0400 Original-Received: from n66644228.ipcdsl.net ([66.64.4.228] helo=defaultvalue.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17y0aL-0006K0-00 for guile-user@gnu.org; Sat, 05 Oct 2002 21:51:57 -0400 Original-Received: from raven.i.defaultvalue.org (raven.i.defaultvalue.org [192.168.1.7]) by defaultvalue.org (Postfix) with ESMTP id 19519ECC6 for ; Sat, 5 Oct 2002 20:51:57 -0500 (CDT) Original-Received: by raven.i.defaultvalue.org (Postfix, from userid 1000) id D428F18A3; Sat, 5 Oct 2002 20:51:56 -0500 (CDT) Original-To: guile-user@gnu.org In-Reply-To: (prj@po.cwru.edu's message of "Fri, 04 Oct 2002 18:41:36 -0400") Original-Lines: 110 User-Agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2 (i386-pc-linux-gnu) Errors-To: guile-user-admin@gnu.org X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.user:1148 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:1148 prj@po.cwru.edu (Paul Jarc) writes: > which isn't always convenient. I think I ought to be able to > duplicate what I like about use-modules with something like this: > (eval '(load "/path/to/foo.scm") new-environment) (eval-in-module '(primitive-load "/path/to/foo.scm") some-module) might be what you want. > - The manual says (load) will evaluate the file's contents in the > top-level environment. Is that still true inside eval, or will it > load into the specified environment? > - What's the difference between load and primitive-load? I think that's roughly the difference. If I recall right, primitive-load doesn't alter the current-environment and doesn't restore it after the load, but Marius can probably clarify if I'm mistaken. > - Is there a way to load from an already-open port rather than a > filename? Could I just loop with read and eval? Would that handle, > e.g., read-hash-extend properly? I don't see any reason it > wouldn't. I think that should work. > - How do I create a new environment? The documented procedures don't > seem to exist: How about this: $ guile guile> (use-modules (ice-9 safe)) guile> (define msm (make-safe-module)) guile> msm # guile> (module-ref msm 'car) # guile> (eval 'car msm) # guile> (use-modules (ice-9 safe-r5rs)) guile> (define msm (null-environment 5)) guile> msm # guile> (eval 'if msm) # guile> (module-ref msm 'if) # guile> (eval 'unlink msm) Backtrace: In current input: 6: 0* [eval unlink #] ?: 1* unlink : In expression unlink: : Unbound variable: unlink ABORT: (unbound-variable) guile> (module-define! msm 'some-num 5) #f guile> (module-ref msm 'some-num) 5 guile> (eval 'some-num msm) 5 guile> some-num Backtrace: In unknown file: ?: 0* some-num : In expression some-num: : Unbound variable: some-num ABORT: (unbound-variable) guile> (module-use! (current-module) msm) #f guile> some-num 5 guile> (module-public-interface msm) #f guile> (define foo (resolve-module '(ice-9 safe))) guile> (module-use! (current-module) (module-public-interface foo)) #f guile> (module-public-interface foo) # guile> etc. > guile> (null-environment 5) > :29:1: In expression (null-environment 5): > :29:1: Unbound variable: null-environment > ABORT: (unbound-variable) > guile> (scheme-report-environment 5) > :30:1: In expression (scheme-report-environment 5): > :30:1: Unbound variable: scheme-report-environment > ABORT: (unbound-variable) > guile> (assv-ref %guile-build-info 'guileversion) > "1.6.0" or perhaps just (version) :> Hope this helps. -- Rob Browning rlb @defaultvalue.org, @linuxdevel.com, and @debian.org Previously @cs.utexas.edu GPG=1C58 8B2C FB5E 3F64 EA5C 64AE 78FE E5FE F0CB A0AD _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user