* libguile/load.c (compiled_is_newer): Tweak diagnostic output.
(do_try_autocompile, autocompile_catch_handler, scm_try_autocompile):
Rework to compute the name of the compiled file in advance. If the
computed name is different from the found .go file and is fresh, use it
directly.
Fixes the case where /usr/lib/.../foo.go is out of date but the user
doesn't have permissions to recompile, so we use the user's local
compile cache instead if it's fresh.
(scm_primitive_load): Pass the found .go file as well to
scm_try_autocompile.
* am/guilec (.scm.go): Set GUILE_AUTO_COMPILE=0 when compiling individual
files, and remove the mkdir -p as compile-file takes care of that now.
* libguile/load.c (do_try_autocompile, autocompile_catch_handler)
(scm_try_autocompile, scm_init_load): Implement autocompilation.
* libguile/script.c (scm_shell_usage, scm_compile_shell_switches): Add
--autocompile / --no-autocompile command-line options, and support for
the GUILE_AUTO_COMPILE environment variable, defaulting to
autocompilation enabled.
* libguile/init.c (scm_load_startup_files): Use
scm_c_primitive_load_path.
* libguile/load.c (scm_primitive_load_path): Add an optional arg,
exception_on_error, which if #f will cause primitive-load-path to just
return #f if no file is found. This is to help out the semantics of
try-module-autoload. We can't just catch misc-error, because loading
the file could raise any exception.
(scm_c_primitive_load_path): Add the extra arg to
scm_primitive_load_path.
* libguile/load.h: Adapt scm_primitive_load_path prototype.
* module/ice-9/boot-9.scm (try-module-autoload): Refactor slightly to be
clearer.
* libguile/load.c (compiled_is_newer): Factored out of
scm_primitive_load_path.
(scm_try_autocompile): New stub, for autocompiling. Currently just
returns false.
(scm_primitive_load_path): Refactor, and call out to
scm_try_autocompile if the .go is missing or not fresh.
* module/system/base/compile.scm (ensure-writable-dir): Rename from
ensure-directory.
(dsu-sort): Helper, does a decorate / sort / undecorate.
(compiled-file-name): Refactor to only return a writable filename. The
readable case is handled by load.c now, and the other case was silly.
Hopefully it will do the right thing.
(load-ensuring-compiled): Remove, load.c will call out to compile-file
if necessary.
(ensure-fallback-path): Remove, load.c will add the ~/.guile-ccache dir
to the load-compiled path, which will prompt its creation if necessary.
* module/ice-9/boot-9.scm (file-exists?): Change to use the stat
interface that doesn't throw exceptions.
(try-module-autoload): Simplify to take advantage of the fact that
primitive-load-path does the right thing with regards to loading
compiled files if they are available.
* libguile/filesys.h:
* libguile/filesys.c (scm_stat): Add optional arg, exception-on-error,
which if #f (not the default) will just return #f instead of raising an
exception if the stat fails.
* libguile/Makefile.am (libpath.h): Add definitions for SCM_CCACHE_DIR
and SCM_EFFECTIVE_VERSION. These are private, the header is not
installed. Add ccachedir to build-info. Rework some other build-info
definitions.
* libguile/load.c (scm_loc_load_compiled_path): New global, corresponding
to the new environment variable, GUILE_LOAD_COMPILED_PATH. Compiled
files will now be searched for in this path, and only in this path.
(scm_init_load_path): Init the load-compiled path too. We initialize it
with $pkglibdir/guile/$effective_version/ccache, and also with
$HOME/.guile-ccache/$effective_version/. This will respect the
libdir/datadir difference, and it is a preparation for automatic
compilation support.
(scm_primitive_load_path): Search only the GUILE_LOAD_COMPILED_PATH for
compiled files.
(scm_init_load): Cache scm_loc_load_compiled_path.
* libguile/read.c (flush_ws, scm_read_commented_expression)
(scm_read_sharp): Add support for commenting out expressions with #;.
(scm_read_syntax, scm_read_sharp): Add support for #', #`, #, and #,@.
* module/ice-9/boot-9.scm: Remove #' read-hash extension, which actually
didn't do anything at all. It's been there since 1997, but no Guile
code I've ever seen uses it, and it conflicts with #'x => (syntax x)
from modern Scheme.
* module/system/base/compile.scm (compile-and-load): Whoops, fix a number
of bugs here.
* libguile/threads.c (scm_join_thread_timed): Recheck t->exited before
looping round to call block_self again, in case thread t has now
exited.
* test-suite/tests/threads.test ("don't hang when joined thread
terminates in SCM_TICK"): New test.
* libguile/threads.c (fat_mutex_unlock): Unblock asyncs when breaking
out of loop.
* test-suite/tests/threads.test (asyncs-still-working?): New function,
to test if asyncs are working (i.e. unblocked). Use this throughout
threads.test, in particular before and after the "timed locking
succeeds if mutex unlocked within timeout" test.
* libguile/frames.c:
* libguile/frames.h:
* libguile/instructions.c:
* libguile/instructions.h:
* libguile/objcodes.c:
* libguile/objcodes.h:
* libguile/programs.c:
* libguile/programs.h:
* libguile/vm-bootstrap.h:
* libguile/vm-engine.c:
* libguile/vm-engine.h:
* libguile/vm-expand.h:
* libguile/vm-i-scheme.c:
* libguile/vm.c:
* libguile/vm.h: Update to use SCM_API and SCM_INTERNAL correctly. Adjust
copyright to be the same as the copyright of Guile itself, which should
be fine given that the FSF holds the whole thing.
* module/ice-9/boot-9.scm (default-pre-unwind-handler): Since we were
tail-called by pre-unwind-handler-dispatch, we can't use
pre-unwind-handler-dispatch as a narrowing argument. Instead just
narrow by one frame.
(pre-unwind-handler-dispatch): Deprecate.
(error-catching-loop): Remove crack comment and code, and just use
default-pre-unwind-handler as our pre-unwind handler.
* module/ice-9/stack-catch.scm (stack-catch):
* module/system/repl/repl.scm (call-with-backtrace): Use
default-pre-unwind-handler directly.
* libguile/__scm.h (SCM_API, SCM_INTERNAL): Take the reverse strategy: symbols will
be hidden by default, and only exported with SCM_API. In addition to working
on Mac OS, it has the several nice efficiency benefits on Linux, and unifies
codepaths with Win32.
* libguile/Makefile.am: Define BUILDING_LIBGUILE when building Guile.
* doc/ref/api-procedures.texi (Compiled Procedures): Fix for API changes.
* doc/ref/compiler.texi (Compiling to the Virtual Machine): Replace GHIL
docs with Tree-IL docs. Update the bits about the Scheme compiler to
talk about Tree-IL and the expander instead of GHIL. Remove
<glil-argument>. Add placeholder sections for assembly and bytecode.
* doc/ref/vm.texi: Update examples with what currently happens. Reword
some things. Fix a couple errors.
* libguile/vm-i-system.c (externals): Remove this instruction, it's not
used.
* module/ice-9/documentation.scm (object-documentation): If the object is
a macro, try to return documentation on the macro transformer.
* module/language/assembly/disassemble.scm (disassemble-load-program):
Fix problem in which we skipped the first element of the object vector,
because of changes to procedure layouts a few months ago.
* module/language/scheme/spec.scm (read-file): Remove read-file
definition.
* module/language/tree-il.scm: Reorder exports. Remove <lexical>, it was
a compat shim to something that was never released. Fix `location'.
* module/language/tree-il/primitives.scm (/): Fix expander for more than
two args to /.
* module/system/base/compile.scm (read-file-in): Remove unused
definition.
* module/system/base/language.scm (system): Remove language-read-file.
* module/language/ecmascript/spec.scm (ecmascript): Remove read-file
definition.
* module/srfi/srfi-35.scm: Use `(ice-9 syncase)'.
(define-condition-type, condition): Rewritten using `syntax-rules'.
(compound-condition, condition-instantiation): New helper internal
macros. Thanks to Andy Wingo for his help!
* module/ice-9/psyntax.scm (source-annotation): Return #f if
source-properties returns null.
(source-wrap): Rework a bit.
(syntax-type): Don't throw away source info for wrapped expressions.
Can has source location info, fools!
(chi-body): Correctly propagate source info for body subforms.
(syntax): Remove special case for map, it doesn't apply (ahem) for
Guile.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm: Remove references to annotation objects,
we're just going to try and use Guile's source properties now. It works
until `syntax' reconstructs output, at which point it seems we lose it.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/psyntax.scm (chi-body): Fix a problem introduced in
dc1eed52f7, that internal syntax definitions were included in the id
lis along with value definitions. Only showed up on a second bootstrap.
Psyntax, how I love thee.
* module/ice-9/psyntax-pp.scm
* module/language/tree-il/optimize.scm:
* module/language/tree-il/primitives.scm: Move primitive-related things
to primitive.scm from inline.scm and optimize.scm.
* module/Makefile.am: Update for inventory changes.
* module/language/tree-il/compile-glil.scm (flatten-lambda): Fix source
emission.
* test-suite/tests/tree-il.test (strip-source): Strip source info on
tree-il before compiling, so we don't get extraneous source info in the
glil. Make check passes!
* module/language/tree-il/compile-glil.scm (flatten-lambda): Fix bad call
to make-glil-src, unfortunately not hit during production because
psyntax doesn't yet understand source locations.
* module/ice-9/threads.scm: Move syntax definitions before the procedures
that use them, and rewrite as hygienic macros since they are so much
nicer that way. Fixes the thread tests.
* test-suite/tests/syntax.test ("top-level define"): Remove the test for
currying, as we don't do that any more by default. It should be easy
for the user to add in if she wants it, though.
("do"): Remove unmemoization tests, as sc-expand fully expands `do'.
("while"): Remove while tests in empty environments. They have been
throwing 'unresolved, and the problem they seek to test is fully
handled by hygiene anyway.
And otherwise tweak expected exception strings, and everything passes!
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
* module/language/tree-il.scm (tree-il->scheme):
* module/ice-9/psyntax.scm (build-conditional): Attempt to not generate
(if #f #f) as the second arm of an if, but it doesn't seem to be
successful.
* module/ice-9/psyntax-pp.scm (syntax-rules): Regenerate.
* test-suite/tests/syntax.test (exception:unexpected-syntax): Change
capitalization.
("unquote-splicing"): Update test.
("begin"): Add in second arms on these ifs, to avoid the strange though
harmless expansion of `if'.
(matches?): New helper macro.
("lambda"): Match on lexically bound symbols, as they will be
alpha-renamed.
* module/language/tree-il/compile-glil.scm (flatten): Actually apply only
needs one arg after the proc. And shit, call/cc and apply in drop
contexts also need to be able to return arbitrary numbers of values;
work it by trampolining through their applicative (non-@) definitions.
Also, simplify the single-valued drop case to avoid the
truncate-values.
* module/language/tree-il/inline.scm (call/cc):
* module/language/tree-il/optimize.scm (*interesting-primitive-names*):
Define call/cc as "interesting". Perhaps we should be hashing on value
and not on variable.
* test-suite/tests/tree-il.test ("application"): Fix up test for new,
sleeker output. (Actually the GLIL is more verbose, but the assembly is
better.)
("apply", "call/cc"): Add some more tests.
* module/language/tree-il/compile-glil.scm (flatten): For applications in
"drop" context, allow the procedure to return unspecified values
(including 0 values).
* test-suite/tests/tree-il.test ("application"): Adapt test.
* module/srfi/srfi-18.scm (wrap): Clarify.
* test-suite/tests/srfi-18.test: Fix so that the expression importing
srfi-18 is expanded before the tests. However the tests are still
failing, something about 0-valued returns...
* module/oop/goops.scm (method): Reimplement as a hygienic macro. This
seriously took me like 6 hours to figure out. Allows for lexical
specializers: (let ((<x> ...)) (define-method (foo (arg <x>)) ...)).
* module/oop/goops/compile.scm (next-method?, compile-make-procedure):
Remove these, as `method' does it all now, hygienically.
* libguile/posix.c: Always use <sys/file.h>, which is provided by
Gnulib.
(flock)[__MINGW32__]: Remove.
(scm_flock): Compile unconditionally. Always use Gnulib's flock(2).
* m4/gnulib-cache.m4 (gl_MODULES): Add `flock' (provides flock(2)
declaration and implementation), `fpieee' (fixes floating point
behavior on Alpha and SH), `stdlib' (provides an unsetenv(3)
declaration, among others), `putenv' (provides a putenv(3) declaration
and implementation with the semantics we need).