* module/ice-9/boot-9.scm (exception-kind, exception-args): Export.
* module/ice-9/exceptions.scm (exception-kind, exception-args):
Re-export.
* module/srfi/srfi-18.scm: Rewrite exception support in terms of core
exceptions, not SRFI-34/35.
* test-suite/tests/srfi-18.test: Since Guile doesn't expose the current
exception handler as such, SRFI-18 captures it using delimited
continuations. This means that we can't compare the result
of (current-exception-handler) with the installed handler using eq?,
even though the procedures are indeed equivalent. So, instead test
handler behavior.
* libguile/exceptions.c:
* libguile/exceptions.h: New files.
* libguile.h: Add exceptions.h.
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
(DOT_X_FILES, DOT_DOC_FILES, modinclude_HEADERS): Add exceptions.c and
exceptions.h.
* libguile/init.c (scm_i_init_guile): Initialize exceptions.
* libguile/threads.c (scm_spawn_thread): Use new names for
scm_i_make_catch_handler and scm_c_make_thunk.
* libguile/throw.c: Rewrite to be implemented in terms of
with-exception-handler / raise-exception.
* libguile/throw.h: Use data types from exceptions.h. Move
scm_report_stack_overflow and scm_report_out_of_memory to
exceptions.[ch].
* module/ice-9/boot-9.scm (&error, &programming-error)
(&non-continuable, make-exception-from-throw, raise-exception)
(with-exception-handler): New top-level definitions.
(throw, catch, with-throw-handler): Rewrite in terms of
with-exception-handler and raise-exception.
: New top-level definitions.
* module/ice-9/exceptions.scm: Adapt to re-export &error,
&programming-error, &non-continuable, raise-exception, and
with-exception-handler from boot-9.
(make-quit-exception, guile-quit-exception-converter): New exception
converters.
(make-exception-from-throw): Override core binding.
* test-suite/tests/eval.test ("inner trim with prompt tag"): Adapt to
"with-exception-handler" being the procedure on the stack.
("outer trim with prompt tag"): Likewise.
* test-suite/tests/exceptions.test (throw-test): Use pass-if-equal.
* module/srfi/srfi-34.scm: Reimplement in terms of core exceptions, and
make "guard" actually re-raise continuations with the original "raise"
continuation.
* module/ice-9/exceptions.scm: New file, derived from (rnrs
conditions). Perhaps unadvisedly, in this file I've renamed a number
of the identifiers. I have never found that the R6RS identifiers made
sense to me. For now this is an internal module that R6RS and SRFI-35
will be based on.
* module/Makefile.am (SOURCES): Add the new file.
* module/rnrs/conditions.scm (rnrs): Export renamed identifiers
from (ice-9 exceptions).
* module/ice-9/boot-9.scm (record-type-uid): New accessor.
(make-record-type): Record UID in record type properties.
* module/rnrs/conditions.scm (define-condition-type): Fix invalid
invocation of make-record-type.
* module/rnrs/records/inspection.scm: Rewrite to use core record
inspection facilities.
* module/rnrs/records/procedural.scm: Rewrite to use core
make-record-type. Incidentally the result is that instances of
derived R6RS record types are now flat instead of nested.
* test-suite/tests/r6rs-records-procedural.test
("make-record-type-descriptor"): Relax a couple condition type checks,
while we redo the exception system.
* module/ice-9/boot-9.scm (make-record-type): Allow (mutable NAME)
or (immutable NAME) as a field name, and record field mutability in a
bitfield.
(record-modifier): Throw an error if the field isn't mutable.
* test-suite/tests/records.test ("records"): Add tests.
* doc/ref/api-data.texi (Records): Update.
* module/ice-9/boot-9.scm (make-record-type): Validate that the fields
are a unique list of symbols. Deprecate passing a string as a type
name.
* module/system/base/syntax.scm (define-record): Update to pass a symbol
as a type name.
* test-suite/tests/records.test (rtd-foo, rtd-fŏŏ, "records"): Adapt to
make record types with symbol names.
* module/ice-9/boot-9.scm (make-record-type): Don't allow subtyping of
final types.
(%record-type-error): Remove helper.
(record-accessor, record-modifier): Use computed record type
predicate, to allow for subtyping.
(define-record-type): Adapt to %record-type-error going away; these
types are final so no accessor adaptation is needed.
* test-suite/tests/records.test: Add tests.
* doc/ref/api-data.texi (Records): Update.
* module/ice-9/boot-9.scm (record-type-vtable): Add slots for "flags"
and a parent vector.
(record-type-name, record-type-fields): Move up in the file.
(record-type-constructor, record-type-flags, record-type-parents): New
accessors.
(make-record-type): Take #:final? and #:parent keyword arguments.
(record-constructor): Delegate to record-type-constructor.
(record-predicate): For non-final types --types that can be extended
by subtyping -- implement an O(1) type predicate.
(define-record-type): Initialize the new fields.
* module/srfi/srfi-9.scm (%define-record-type): Initialize flags and
parent fields.
* module/ice-9/channel.scm: Remove. This file has had a bug since
2.0 or so that prevented loading the module; I can only conclude that
it hasn't worked for years.
* module/Makefile.am (SOURCES): Remove ice-9/channel.scm.
* module/ice-9/peg/using-parsers.scm (prec): Use SRFI-9 to define PEG
record types.
(peg:start, peg:end, peg:string, peg:tree, peg:substring): Implement
in a more efficient way.
* module/ice-9/safe-r5rs.scm: Define local versions of `case' and `cond'
that assume aux syntax is unbound. If this doesn't work, we can
switch to exporting aux syntax.
* module/ice-9/top-repl.scm (top-repl): Don't add (ice-9 r5rs) to the
REPL environment.
* module/ice-9/boot-9.scm (else, =>, ..., _): New definitions. These
are specified by the r6rs and the r7rs.
* module/ice-9/sandbox.scm (core-bindings): Include the aux syntax
definitions.
* module/rnrs/base.scm:
* module/rnrs.scm: Re-export aux syntax.
Since the change in 2.2 noted in the NEWS as "Fix literal matching for
module-bound literals", defining `_' makes `syntax-rules' and `match'
fail to recognize `_' as the catch-all literal. This change adapts the
recommendations to current practice in 2.2, as users have had to adapt
to this change.
* doc/ref/api-i18n.texi (Gettext Support): Update documentation.
* module/language/tree-il/analyze.scm (proc-ref?, gettext?): G_ is the
conventional abbreviation, not _.
* test-suite/tests/tree-il.test: Adapt.
* module/ice-9/command-line.scm: Use G_ instead of _.
This change to the expander allows mixed local definitions and
expressions. The expansion turns:
(let () (a) (define (b) 42) (b) (b))
into:
(let ()
(letrec* ((t0 (begin (a) (if #f #f)))
(b (lambda () 42)))
(b)))
Which is to say, expressions that precede definitions are expanded as
definitions of a temporary via (begin EXP (if #f #f)).
* module/ice-9/psyntax.scm (expand-body): Allow mixed definitions and
expressions.
* module/ice-9/psyntax-pp.scm: Regenerate.
* test-suite/tests/syntax.test: Add a couple tests and update for new
error messages.
* doc/ref/api-modules.texi (Declarative Modules): New subsection.
* module/ice-9/boot-9.scm (module): Change eval-closure slot, which was
deprecated and unused, to be a "declarative?" slot, indicating that
definitions from the module are declarative.
(user-modules-declarative?): New parameter.
(make-fresh-user-module): Set declarative according to parameter.
(define-module*, define-module): Add #:declarative? keyword argument,
defaulting to the value of user-modules-declarative? parameter when
the module was expanded.
(guile-user): This module is not declarative.
* module/language/tree-il/letrectify.scm (compute-declarative-toplevels):
Use the new declarative? module flag.
Add "mod" field to <toplevel-ref>, <toplevel-set>, and
<toplevel-define>, indicating the expander's idea of what the current
module is when a toplevel variable is accessed or created. This will
help in later optimizations.
* libguile/expand.c (TOPLEVEL_REF, TOPLEVEL_SET, TOPLEVEL_DEFINE)
(expand, expand_define, expand_set_x, convert_assignment):
* libguile/expand.h (SCM_EXPANDED_TOPLEVEL_REF_FIELD_NAMES):
(SCM_MAKE_EXPANDED_TOPLEVEL_REF, SCM_EXPANDED_TOPLEVEL_SET_FIELD_NAMES):
(SCM_MAKE_EXPANDED_TOPLEVEL_SET, SCM_EXPANDED_TOPLEVEL_DEFINE_FIELD_NAMES):
(SCM_MAKE_EXPANDED_TOPLEVEL_DEFINE):
* module/ice-9/compile-psyntax.scm (translate-literal-syntax-objects):
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm:
* module/language/tree-il.scm:
* module/language/tree-il.scm (parse-tree-il, make-tree-il-folder):
(pre-post-order):
* module/language/tree-il/analyze.scm (goops-toplevel-definition):
(macro-use-before-definition-analysis, proc-ref?, format-analysis):
* module/language/tree-il/compile-cps.scm (convert):
* module/language/tree-il/debug.scm (verify-tree-il):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/fix-letrec.scm (free-variables):
* module/language/tree-il/peval.scm (peval):
* test-suite/tests/tree-il.test: Adapt uses.
* module/ice-9/format.scm (format): Refactor naming of some local
variables. Assigned variables get a % sigil before them. Also, avoid
the mutable-error dance.
This binding was forgotten when (ice-9 ports) was introduced in
44b3342c4d. Thus it has always been
missing in Guile 2.2.
* module/ice-9/ports.scm: Export 'current-load-port'.
* module/ice-9/suspendable-ports.scm (get-bytevector-n!): New procedure.
(get-bytevector-n): Rewrite in terms of 'get-bytevector-n!'.
(port-bindings): Add 'get-bytevector-n!'.