guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: loading a module via an absolute path


From: Paul Jarc
Subject: Re: loading a module via an absolute path
Date: Mon, 07 Oct 2002 13:09:21 -0400
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i686-pc-linux-gnu)

Rob Browning <address@hidden> wrote:
> address@hidden (Paul Jarc) writes:
>> - 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.

If that's right, then the documentation needs to be fixed.  1.6.0:
 - Scheme Procedure: load filename
     Load FILENAME and evaluate its contents in the top-level
     environment.  The load paths are not searched.  If the variable
     `%load-hook' is defined, it should be bound to a procedure that
     will be called before any code is loaded.  See documentation for
     `%load-hook' later in this section.
...
 - Scheme Procedure: primitive-load filename
 - C Function: scm_primitive_load (filename)
     Load the file named FILENAME and evaluate its contents in the
     top-level environment. The load paths are not searched; FILENAME
     must either be a full pathname or be a pathname relative to the
     current directory.  If the  variable `%load-hook' is defined, it
     should be bound to a procedure that will be called before any code
     is loaded.  See the documentation for `%load-hook' later in this
     section.

This should also specify what load does with a relative path.  It's
easy enough to guess, but the fact that it's specified for
primitive-load and not for load introduces doubt.

>> - 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.

Ok, I'll probably do that then.

>> - 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> (use-modules (ice-9 safe-r5rs))
>   guile> (define msm (null-environment 5))

Thanks, that seems to work.  The manual doesn't mention the need for
(ice-9 safe-r5rs) in the Environments node, and make-safe-module is
undocumented.

>> guile> (assv-ref %guile-build-info 'guileversion)
>> "1.6.0"
>
> or perhaps just (version) :>

Yeah, that too.


paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]