* module/language/tree-il/fix-letrec.scm (partition-vars): Previously,
for letrec* we treated all unreferenced vars as complex, because of
orderings of effects that could arise in their definitions. But we
can actually keep simple and lambda vars as unreferenced, as their
initializers cannot cause side effects.
(fix-letrec!): Remove letrec* -> letrec code, as it's unneeded.
The expansion of `define-inlinable' contained an expression, which made
SRFI-9's `define-record-type' fail in non-toplevel contexts ("definition
used in expression context").
* module/srfi/srfi-9.scm (define-inlinable): Get rid of apparently
useless expression in the expansion, so the expansion yields only
definitions. At the same time, use a space in the generated names to
lessen the chances of name conflicts, also avoiding -Wunused-toplevel
warnings.
* test-suite/tests/srfi-9.test (non-toplevel): New test verifying that
`define-record-type' works in non-toplevel context as well.
* doc/ref/srfi-modules.texi (SRFI-9 - define-record-type): Add
subsubsection noting that Guile does not enforce top-levelness.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* module/ice-9/boot-9.scm (while): Report an error if `continue' is
passed one or more arguments. Previously, it would report an error if
`(continue arg rest ...)' was found within the `while', but not if
`continue' was found bare and later applied to one or more arguments,
e.g. `(apply continue (list arg rest ...))'.
* module/language/tree-il/fix-letrec.scm (fix-letrec!): When X is a
`letrec*' with only lambdas and simple expressions, analyze it as if
it were a `letrec'.
* test-suite/tests/tree-il.test ("letrec"): Add test for
`(letrec* (x y) (xx yy) ((const 1) (const 2)) (lexical y yy))'.
* module/Makefile.am:
* module/ice-9/eval-string.scm: New module, for use in implementing the
scm_c_eval_string_from_file_line suggestion.
* test-suite/Makefile.am:
* test-suite/tests/eval-string.test: New tests.
* module/system/repl/command.scm (terminal-width): New parameter that
will use the true terminal width if unset.
(backtrace, locals): Default to (terminal-width).
(width): Simplify.
This meta-command allows one to set the default number of columns
that output from ,backtrace and ,locals shall occupy.
* doc/ref/scheme-using.texi (Debug Commands): document ,width
* module/system/repl/command.scm (*width*): new var
(backtrace, locals): use *width* in optarg
(width): new meta-command
* module/system/repl/repl.scm (read-comment, read-scheme-line-comment)
(read-scheme-datum-comment): New helpers.
(meta-reader): Take a language instead of a reader. If we have a
nonwhitespace char, first check to see that it's a comment, and if so,
read it off and loop.
(prompting-meta-read): Call meta-reader with the lang.
* module/system/repl/repl.scm (flush-leading-whitespace): Rename from
next-char.
(meta-reader): Use flush-leading-whitespace.
(run-repl): Use flush-to-newline after the evaluation, which seems to
be the same as what we did before.
* module/ice-9/boot-9.scm (module-use-interfaces!): Fix up to prevent
duplication in the use list of multiple incoming interfaces.
* test-suite/tests/modules.test ("module-use"): Add tests.
This fixes a problem with R6RS's `import' in particuliar: when importing
a subset of a library/module, the interface created for that purpose
inherits the name of the module it is derived from. The low-level
primitives that are used for importing would then disregard earlier
imports from the same module.
An example for this bug can be seen with the following library
definition:
(library (test-guile2)
(export foo)
(import (only (rnrs base) define)
(only (rnrs base) error))
(define (foo . args)
#t))
In the above, the import of `define' would be disregarded when `error'
is imported, thus leading to a syntax error, since `(foo . args)' is
treated as an application, since the binding of `define' would be not
present.
* module/ice-9/boot-9.scm (module-use!): Remove the filtering of the
existing imports of the module by name; a check for identity is
already done beforehand.
(module-use-interfaces!): Filter the existing imports by identity
instead of filtering them by their names.
* module/system/repl/repl.scm (flush-all-input): New helper.
(prompting-meta-read): Flush all input on a read error, as we could be
within some expression or a string or something.
* module/ice-9/boot-9.scm (scm-error-printer): Allow #f for rest args,
interpreting it as '(). Fixes regexp throws, which are of the form:
(regular-expression-syntax "make-regexp" "Invalid preceding regular expression" #f ("?.*"))
* module/ice-9/psyntax.scm (chi-top-sequence): Manually inline
eval-if-c&e into its two call sites; I found it hard to understand
otherwise. If the mode is just 'e, defer expansion of definitions and
expressions until the end, so that they can be expanded in a context
of all syntax expanders defined in the sequence.
* module/ice-9/psyntax.scm (chi-top-sequence): Pull chi-top into the
body of this toplevel begin expander. This will let us do r6rs
toplevel expansion correctly.
(chi-top): Remove.
(macroexpand): Dispatch to chi-top-sequence directly.
* module/web/uri.scm:
* module/web/server.scm (call-with-output-string*):
(call-with-output-bytevector*): Local procs to output to strings or
bytevectors, *and then close the port*. We can't make this change in
call-with-output-string because it would be incompatible.
* module/web/uri.scm (call-with-encoded-output-string, decode-string)
(uri-decode)
* module/web/server.scm (call-with-encoded-output-string): Use the new
helpers.
* module/ice-9/popen.scm (open-pipe*): Hack around the lack of an
after-gc hook, and pump the pipes guardian here in the procedure that
adds to the guardian.
* module/rnrs/base.scm (define-proxy): New macro.
(raise, condition, make-error, make-assertion-violation,
make-who-condition, make-message-condition, make-irritants-condition):
Use it.
* module/ice-9/binary-ports.scm: New module.
* module/Makefile.am: Add to makefile.
* module/rnrs/io/ports.scm: Re-export bindings from (ice-9 binary
ports). This will allow the compiler to not pull (rnrs) into its
included module set.
* module/oop/goops.scm (ensure-generic): If the old definition of a
desired getter is a primitive generic, let the new method be added to
it instead of creating a fresh new generic.
(ensure-accessor): Modify as necessary to keep the old behavior.
Maybe something more optimal can be done here, but it's not yet
obvious to me how to do it.
* module/ice-9/boot-9.scm (the-scm-module): Make it its own public
interface.
* test-suite/tests/modules.test ("foundations")["the-root-module",
"the-scm-module"]: New tests.
* module/ice-9/boot-9.scm (load-in-vicinity): New helper, loads a file
relative to a path.
(load): Turn into a macro that captures the name of the source file
being expanded, and dispatches to load-in-vicinity. Referencing
`load' by bare name returns a closure that embeds the current source
file name.
* libguile/read.c (scm_read_opts): Default "positions" to #t. The
compiler was already turning it on anyway, and this allows
primitive-load without --auto-compile to also propagate source
information through the expander, for better errors and to let macros
know their source.
* module/language/scheme/spec.scm: No need to enable positions here
now.
* libguile/backtrace.c (scm_print_exception): Add C binding for
print-exception, which dispatches to whatever is defined in Scheme.
(boot_print_exception): Add initial binding, replaced later in
Scheme.
* module/ice-9/boot-9.scm: Expect there to already be a print-exception
binding.
* module/system/repl/error-handling.scm (error-string): Just use
print-exception instead of rolling our own printer.
(call-with-error-handling): Simplify.
* module/ice-9/boot-9.scm (set-exception-printer!, print-exception):
Define an extensible exception-printing mechanism.
Also register printers for all keys thrown by Guile.
Inspired by a patch by Andreas Rottmann.
* libguile/frames.c (scm_frame_source): Don't call out to (system vm
frames), as this routine is used when printing exceptions. Make
available in the default environment (ugh).
* module/system/vm/frame.scm: Remove frame-source definition and
export.
* libguile.h:
* libguile/Makefile.am:
* libguile/deprecated.h:
* libguile/deprecated.c:
* libguile/init.c:
* libguile/properties.c:
* libguile/properties.h: Deprecate the "primitive properties"
interface. It was only used to implement object properties, and that
is no longer the case.
* module/ice-9/boot-9.scm (make-object-property): Reimplement just in
terms of weak hash tables, and make threadsafe.
* NEWS:
* doc/ref/api-utility.texi: Update.
* module/ice-9/getopt-long.scm (fatal-error): New helper. For errors
that come from the user -- i.e., not the grammar -- we will handle our
own error printing and call `exit' rather than relying on the root
catch handler. This is more friendly to the user than a Scheme
backtrace.
(parse-option-spec, process-options, getopt-long): Call `fatal-error'
as appropriate.
* test-suite/tests/getopt-long.test (pass-if-fatal-exception): New
helper, checks that a certain key was thrown to, and that suitable
output has been printed on an error port.
(deferr): Change to expect a 'quit key instead of 'misc-error. Update
exceptions to not match the beginning of the string, as that will be
the program name. Update tests to use pass-if-fatal-exception.