unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* file names embedded in .go
@ 2010-04-19 14:52 Andy Wingo
  2010-04-19 21:46 ` Thien-Thi Nguyen
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Andy Wingo @ 2010-04-19 14:52 UTC (permalink / raw)
  To: guile-devel

Hey all,

I recently added a global fluid, %file-port-name-canonicalization, which
defaults to #f. But if it's 'absolute, the port name of a file port will
be canonicalized to the absolute path; or, if it's 'relative, the port
name is the canonical name of the file, relative to the %load-path, or
the file name as given otherwise.

The intention was to allow the user to control (port-filename P), so
that the user could find e.g. the absolute path corresponding to that
port at the time that it was made.

The 'relative mode is particularly useful, because it's the
`port-filename' that gets embedded in a .go file. Oftentimes you would
want to be able to map a .go file to a corresponding .scm, and currently
it's difficult. For example if you compile in a +build subdirectory of
Guile via `../configure', then the `port-filename' is e.g.
"../../module/ice-9/boot-9.scm", which doesn't make any sense.

One could instead embed the absolute path, but then you have the problem
that you might remove your build or source directory; it doesn't make
sense to have installed files pointing to build paths. DWARF does this,
but only because with C you don't install the source, but with Guile you
should.

So for me the right thing to do, by default, is to embed a path relative
to the `%load-path', so that one can find the source file via something
like:

    (use-modules (system vm program))
    (define (program-source-file p)
      (search-path %load-path (source:file (program-source p 0))))

I added a keyword argument to compile-file and compile-and-load for this
purpose, to parameterize %file-port-name-canonicalization during the
extent of the given file's compilation. So now files compiled with
guile-tools compile will have their relative path embedded in them, so
that we can map .go files to .scm files, whether installed or
uninstalled.

Thoughts?

Andy
-- 
http://wingolog.org/




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

end of thread, other threads:[~2010-04-22 12:50 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-19 14:52 file names embedded in .go Andy Wingo
2010-04-19 21:46 ` Thien-Thi Nguyen
2010-04-20  0:08   ` Jose A. Ortega Ruiz
2010-04-20 11:35     ` Thien-Thi Nguyen
2010-04-20 19:15       ` Jose A. Ortega Ruiz
2010-04-21  7:45         ` Thien-Thi Nguyen
2010-04-20  9:45   ` Andy Wingo
2010-04-20 10:34     ` Thien-Thi Nguyen
2010-04-19 23:12 ` port-filename and path canonicalization Ludovic Courtès
2010-04-20  9:42   ` Andy Wingo
2010-04-20 11:15     ` Thien-Thi Nguyen
2010-04-21  8:49       ` Ludovic Courtès
2010-04-21 19:16         ` Thien-Thi Nguyen
2010-04-21 22:26           ` Ludovic Courtès
2010-04-22  7:42             ` Thien-Thi Nguyen
2010-04-20 16:57     ` Ludovic Courtès
2010-04-22 11:10       ` Andy Wingo
2010-04-22 12:50         ` Ludovic Courtès
2010-04-19 23:23 ` file names embedded in .go 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).