From: Andy Wingo <wingo@pobox.com>
To: Ian Price <ianprice90@googlemail.com>
Cc: Ian Hulin <ian@hulin.org.uk>, 10327-done@debbugs.gnu.org
Subject: bug#10327: Please document include and include-from-path
Date: Fri, 27 Jan 2012 16:31:31 +0100 [thread overview]
Message-ID: <87aa59go18.fsf@pobox.com> (raw)
In-Reply-To: <87ehvu975c.fsf@Kagami.home> (Ian Price's message of "Fri, 23 Dec 2011 23:53:51 +0000")
Hello Ian & Ian :)
Thanks for the report. I added some extensive docs.
6.17.11 Local Inclusion
-----------------------
This section has discussed various means of linking Scheme code
together: fundamentally, loading up files at run-time using `load' and
`load-compiled'. Guile provides another option to compose parts of
programs together at expansion-time instead of at run-time.
-- Scheme Syntax: include file-name
Open FILE-NAME, at expansion-time, and read the Scheme forms that
it contains, splicing them into the location of the `include',
within a `begin'.
If you are a C programmer, if `load' in Scheme is like `dlopen' in
C, consider `include' to be like the C preprocessor's `#include'. When
you use `include', it is as if the contents of the included file were
typed in instead of the `include' form.
Because the code is included at compile-time, it is available to the
macroexpander. Syntax definitions in the included file are available to
later code in the form in which the `include' appears, without the need
for `eval-when'. (*Note Eval When::.)
For the same reason, compiling a form that uses `include' results in
one compilation unit, composed of multiple files. Loading the compiled
file is one `stat' operation for the compilation unit, instead of `2*N'
in the case of `load' (once for each loaded source file, and once each
corresponding compiled file, in the best case).
Unlike `load', `include' also works within nested lexical contexts.
It so happens that the optimizer works best within a lexical context,
because all of the uses of bindings in a lexical context are visible,
so composing files by including them within a `(let () ...)' can
sometimes lead to important speed improvements.
On the other hand, `include' does have all the disadvantages of
early binding: once the code with the `include' is compiled, no change
to the included file is reflected in the future behavior of the
including form.
Also, the particular form of `include', which requires an absolute
path, or a path relative to the current directory at compile-time, is
not very amenable to compiling the source in one place, but then
installing the source to another place. For this reason, Guile provides
another form, `include-from-path', which looks for the source file to
include within a load path.
-- Scheme Syntax: include-from-path file-name
Like `include', but instead of expecting `file-name' to be an
absolute file name, it is expected to be a relative path to search
in the `%load-path'.
`include-from-path' is more useful when you want to install all of
the source files for a package (as you should!). It makes it possible
to evaluate an installed file from source, instead of relying on the
`.go' file being up to date.
On Sat 24 Dec 2011 00:53, Ian Price <ianprice90@googlemail.com> writes:
> Or am I being ever so slightly patronising?
"Recursion and condescension"? :-)
http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html
Cheers,
Andy
--
http://wingolog.org/
prev parent reply other threads:[~2012-01-27 15:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-19 15:12 bug#10327: Please document include and include-from-path Ian Hulin
2011-12-23 23:53 ` Ian Price
2012-01-27 15:31 ` Andy Wingo [this message]
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=87aa59go18.fsf@pobox.com \
--to=wingo@pobox.com \
--cc=10327-done@debbugs.gnu.org \
--cc=ian@hulin.org.uk \
--cc=ianprice90@googlemail.com \
/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).