unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* load-from-path and compile-file question
@ 2011-11-06 19:44 Ian Hulin
  2011-11-12 21:11 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Hulin @ 2011-11-06 19:44 UTC (permalink / raw)
  To: guile-user

Hi all,

In LilyPond initialization code, at the moment we build a list of
scheme files to load from our %load-path and interpret as we go.

I'm currently hacking some code so that if we do the load-from-path
successfully we then call
(compile-file (%search-load-path "blah.scm") <output-path>/blah.go).

However one of these file has code using (current-module) to do some
validation on some interpretive code basically looking for a
symbol-name which is defined in the current module and is a procedure.

The procedure works fine and validates as expected when the .scm file
is loaded via load-from-path, but fails validation of exactly the same
symbol when the file is being compiled using compile-file.

I investigated by putting trace commands in the file being compiled to
(format #f "~s" (current-module)) and this showed different results
between when the file was being interpreted after being loaded and
when it was compiling.

(load-from-path) showed the expected module '(lily), (compile-file)
showed an "anonymous" module with an internally generated name.

Tested with Guile V2.0.3.

Is this a bug, or are we doing something seriously screwy in our code?

Cheers,
Ian Hulin




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: load-from-path and compile-file question
  2011-11-06 19:44 load-from-path and compile-file question Ian Hulin
@ 2011-11-12 21:11 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2011-11-12 21:11 UTC (permalink / raw)
  To: guile-user

Hi Ian,

Ian Hulin <ian@hulin.org.uk> skribis:

> (load-from-path) showed the expected module '(lily), (compile-file)
> showed an "anonymous" module with an internally generated name.

If you look at ‘compile’ in (system base compile), you’ll find that it
has an ‘env’ argument, which is the module where compilation takes
place (in the case of Scheme.)

The default value for that module can be found in (language scheme
spec): it’s a fresh module, as you noticed.  The intent is to confine
side-effects that may happen at compile-time.

You can specify another module by just calling
(compile exp #:env my-module).

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-12 21:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-06 19:44 load-from-path and compile-file question Ian Hulin
2011-11-12 21:11 ` Ludovic Courtès

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