From: Rob Browning <rlb@defaultvalue.org>
Subject: Re: loading a module via an absolute path
Date: Sat, 05 Oct 2002 20:51:56 -0500 [thread overview]
Message-ID: <87vg4gl4g3.fsf@raven.i.defaultvalue.org> (raw)
In-Reply-To: <m3ptupygg9.fsf@multivac.cwru.edu> (prj@po.cwru.edu's message of "Fri, 04 Oct 2002 18:41:36 -0400")
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
#<module 8089b50>
guile> (module-ref msm 'car)
#<primitive-procedure car>
guile> (eval 'car msm)
#<primitive-procedure car>
guile> (use-modules (ice-9 safe-r5rs))
guile> (define msm (null-environment 5))
guile> msm
#<interface 807ed30>
guile> (eval 'if msm)
#<primitive-macro! if>
guile> (module-ref msm 'if)
#<primitive-macro! if>
guile> (eval 'unlink msm)
Backtrace:
In current input:
6: 0* [eval unlink #<interface 807ed30>]
?: 1* unlink
<unnamed port>: In expression unlink:
<unnamed port>: 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
<unnamed port>: In expression some-num:
<unnamed port>: 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)
#<interface (ice-9 safe) 808b200>
guile>
etc.
> guile> (null-environment 5)
> <unnamed port>:29:1: In expression (null-environment 5):
> <unnamed port>:29:1: Unbound variable: null-environment
> ABORT: (unbound-variable)
> guile> (scheme-report-environment 5)
> <unnamed port>:30:1: In expression (scheme-report-environment 5):
> <unnamed port>: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
next prev parent reply other threads:[~2002-10-06 1:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-04 22:41 loading a module via an absolute path Paul Jarc
2002-10-06 1:51 ` Rob Browning [this message]
2002-10-07 17:09 ` Paul Jarc
2002-10-07 20:05 ` Paul Jarc
2002-10-18 18:21 ` Paul Jarc
2002-10-18 22:26 ` Marius Vollmer
2002-10-18 23:26 ` Paul Jarc
2002-10-19 10:44 ` Marius Vollmer
2002-10-19 20:42 ` Paul Jarc
2002-10-20 16:19 ` Marius Vollmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vg4gl4g3.fsf@raven.i.defaultvalue.org \
--to=rlb@defaultvalue.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).