1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00
Commit graph

19988 commits

Author SHA1 Message Date
Andy Wingo
4b2c512b94 Update NEWS for records and exceptions work
* NEWS: Update.
* doc/ref/api-data.texi (Records): Fix a typo.
2019-11-14 21:37:00 +01:00
Andy Wingo
95efe14e44 SRFI-18 uses core exceptions
* 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.
2019-11-14 16:33:10 +01:00
Andy Wingo
44ee8c5559 Update documentation for with-exception-handler et al
* doc/ref/api-control.texi (Prompt Primitives): Reference the newer
  exception facilities.
  (Exceptions): Rewrite to use the new exception primitives.
  (Exception Terminology): Remove superfluous section.
  (Exception Objects): New section.
  (Raising and Handling Exceptions): New section.
  (Throw and Catch): New section, coalescing the previous catch,
  with-throw-handler, and throw sections.
  (Exceptions and C): New section, for miscellaneous procedures.
  (Handling Errors): Mention the transitional period regarding exception
  handling.
* doc/ref/api-debug.texi (Catching Exceptions): Rewrite to use newer
  exception facilities.
  (Capturing Stacks): Remove, as it's not really recommendable any
  more.
  (Pre-Unwind Debugging): Rewrite to use the new primitives.
  (Standard Error Handling): Add note about transitional status.
  (Stack Overflow): Reference new exception section.
* doc/ref/api-scheduling.texi (Mutexes and Condition Variables):
  Reference new exception section.
* doc/ref/r6rs.texi (rnrs exceptions, rnrs conditions): Update to
  mention compatibility with SRFI-34/35 and to relate to core
  exceptions.
* doc/ref/srfi-modules.texi (SRFI-34): Document.
2019-11-13 22:33:09 +01:00
Andy Wingo
f4ca107f7f Rebase throw/catch on top of raise-exception/with-exception-handler
* 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.
2019-11-13 22:24:19 +01:00
Andy Wingo
f2c8ff5a52 Remove boot "catch" definition.
* libguile/throw.c (scm_init_throw): Remove boot definition of "catch".
2019-11-07 16:46:53 +01:00
Andy Wingo
3c73d77e2a Move exceptions with key and args to core
* module/ice-9/boot-9.scm (&exception-with-key-and-args)
  (&quit-exception): New definitions.
* module/ice-9/exceptions.scm (make-guile-exception):
  (guile-exception?, guile-exception-key, guile-exception-args): Update
  definitions.
2019-11-07 16:43:23 +01:00
Andy Wingo
92d767bae2 Move the core of exception objects into core
* module/ice-9/boot-9.scm (&exception, &compound-exception)
  (simple-exceptions, make-exception, exception?, exception-type?)
  (make-exception-type, exception-predicate, exception-accessor): Move
  these definitions into core, from (ice-9 exceptions).
* module/ice-9/exceptions.scm: Re-export definitions from core.
2019-11-07 15:55:23 +01:00
Andy Wingo
fc7a0a854f Move exception-handling routines after records in boot-9
* module/ice-9/boot-9.scm: Move down definitions of catch, throw, and so
  on until they are after records.
2019-11-07 15:50:20 +01:00
Andy Wingo
f9b594c482 Move false-if-exception down in boot-9
* module/ice-9/boot-9.scm (false-if-exception): Move down.
2019-11-07 15:07:14 +01:00
Andy Wingo
9835ed1809 Move adapter between "throw" and "raise" exceptions into core
* module/ice-9/exceptions.scm (&guile):
  (default-guile-exception-converter):
  (guile-common-exceptions):
  (convert-guile-exception):
  (&raise-object-wrapper):
  (make-raise-object-wrapper):
  (raise-object-wrapper?):
  (raise-object-wrapper-obj):
  (raise-object-wrapper-continuation):
  (raise-exception):
  (raise-continuable):
  (with-exception-handler):
  (exception-printer):
  (format-exception):
  (format-simple-exception):
  (%exception):
  (guile-syntax-error-converter):
  (guile-lexical-error-converter):
  (guile-assertion-failure-converter):
  (guile-undefined-variable-error-converter):
  (guile-implementation-restriction-converter):
  (guile-external-error-converter):
  (guile-system-error-converter):
  (guile-exception-converters):
  (set-guile-exception-converter!): Move here, from (rnrs exceptions).
* module/rnrs/exceptions.scm: Re-export bindings from (ice-9
  exceptions).
2019-11-05 09:36:36 +01:00
Andy Wingo
86bc3da9e0 Rebase SRFI-35 on top of (ice-9 exceptions)
* module/ice-9/exceptions.scm (exception-type?): New export.
* module/srfi/srfi-35.scm: Rewrite in terms of (ice-9 exceptions).
2019-11-04 15:18:57 +01:00
Andy Wingo
54ab2175f9 Add (ice-9 exceptions) module
* 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).
2019-11-03 21:37:02 +01:00
Andy Wingo
90d52a9e1d Add `record-type-has-parent?'.
* module/ice-9/boot-9.scm (record-type-has-parent?): New function.
* module/srfi/srfi-35.scm (condition-type?): Use it.
2019-11-03 21:36:39 +01:00
Andy Wingo
9f1a671734 Remove circularity in r6rs by rebasing conditions on core records
* module/rnrs/conditions.scm: Use core record facilities to define the
  base condition types, define-condition-type, and the standard
  condition hierarchy.
  (simple-condition?): Rename from condition-internal?.
* module/rnrs/exceptions.scm: Move `raise' definition here, out from the
  procedural records layer.
  (format-simple-condition): Reimplement in a simpler way, hopefully
  producing the same output.
* module/rnrs/records/procedural.scm:
* module/rnrs/records/inspection.scm: Import the exceptions and
  conditions modules, and use the normal raise function.
2019-10-30 15:53:38 +01:00
Andy Wingo
73d0a3bccb Rebase R6RS records on top of core records
* 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.
2019-10-29 11:35:16 +01:00
Andy Wingo
1ae0f8d490 Add record-type-parent definition.
* module/ice-9/boot-9.scm (record-type-parent): New definition.
2019-10-29 10:34:35 +01:00
Andy Wingo
315fabdfe7 Add support for immutable fields in core records
* 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.
2019-10-28 16:59:58 +01:00
Andy Wingo
f963bdf02d Rename final? record type flag; add support for opaque?
* module/ice-9/boot-9.scm (record-type-extensible?): Rename from
  record-type-final?, with the opposite sense.
  (record-type-opaque?): New accessor.
  (make-record-type): Change #:final? to #:extensible?, with the
  opposite meaning.  Add #:opaque? arg.
* test-suite/tests/records.test ("records"): Add opaque tests; update
  extensible tests.
* doc/ref/api-data.texi (Records): Update.
* module/srfi/srfi-35.scm (&condition, make-condition-type): Update for
  make-record-type API change.
2019-10-27 21:31:18 +01:00
Andy Wingo
7a8e314d31 Guile `make-record-type' supports non-generative definition
* module/ice-9/boot-9.scm (prefab-record-types): New definition.
  (make-record-type): Add #:uid keyword.
* test-suite/tests/records.test ("records"): Add tests.
* doc/ref/api-data.texi (Records): Document #:uid
2019-10-27 20:55:01 +01:00
Andy Wingo
958aa8b313 Change record type "flags" field to "properties"
* module/ice-9/boot-9.scm (record-type-properties): Rename from
  record-type-flags.
  (record-type-final?): New accessor.
  (make-record-type):
  (define-record-type):
* test-suite/tests/records.test ("records"): Adapt.
2019-10-27 20:03:51 +01:00
Andy Wingo
04615d3c20 Fix one remaining use of make-record-type with string type name
* test-suite/tests/gc.test ("weak-values versus records"): Fix to pass a
  symbol.
2019-10-23 14:45:36 +02:00
Andy Wingo
99a95383cf Rebase srfi-35 conditions on top of make-record-type
* module/srfi/srfi-35.scm: Import (ice-9 match), and remove now-unused
  srfi-1 import.
  (print-condition): Print more like records, as appears to be the
  intention.
  (&condition): Define using make-record-type.  Adapt all callers.
  Also, compound conditions are now a disjoint type, handled specially
  by condition-ref, condition?, and so on.
* test-suite/tests/srfi-35.test (v3): Fix an error in which a
  subcondition was initialized without initializers for all of its
  fields.
2019-10-23 14:42:35 +02:00
Andy Wingo
f116bd1009 make-record-type does more validation on the fields
* 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.
2019-10-23 14:42:29 +02:00
Andy Wingo
bebc46be14 SRFI-9 uses make-record-type
* module/srfi/srfi-9.scm (%define-record-type): Use make-record-type,
  instead of rolling our own vtable.  Shouldn't have any perf impact.
2019-10-23 12:04:58 +02:00
Andy Wingo
f060f1a4e6 Record accessors respect subtyping
* 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.
2019-10-22 16:22:48 +02:00
Andy Wingo
4bec125e63 Allow records to be subtyped
* 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.
2019-10-22 14:50:14 +02:00
Andy Wingo
6205c2d7d4 Fix deprecated 1-arg `make-module' in tests
* test-suite/tests/modules.test ("circular imports"): Use nullary
  make-module.
2019-10-22 14:00:12 +02:00
Andy Wingo
f7b4055b16 Deprecate two-arg `record-constructor'
* module/ice-9/boot-9.scm (record-constructor): Deprecate the two-arg
  form.
2019-10-22 13:59:33 +02:00
Andy Wingo
0c8d20d2d0 Re-implement (ice-9 gap-buffer) records in terms of srfi-9
* module/ice-9/gap-buffer.scm (gap-buffer): Use srfi-9.
2019-10-22 13:47:02 +02:00
Andy Wingo
40395c0dff Remove (ice-9 channel)
* 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.
2019-10-21 17:34:50 +02:00
Andy Wingo
f152d7cd96 Refactor PEG records
* 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.
2019-10-21 17:21:47 +02:00
Andy Wingo
2cca09126e Extend `import' to allow R7RS-style srfi references
* module/ice-9/r6rs-libraries.scm (resolve-r6rs-interface): Allow for
  srfis to be accessed via (srfi 42 foo) in addition to (srfi :42 foo).
2019-09-27 22:57:38 +02:00
Andy Wingo
3e02bf7259 (ice-9 safe-r5rs) fixes for bound aux syntax
* 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.
2019-09-27 22:57:38 +02:00
Andy Wingo
2e335635cc (ice-9 null) also exports aux syntax, syntax-rules
* module/ice-9/null.scm: Add more syntactic exports.
2019-09-27 22:57:38 +02:00
Andy Wingo
cc7d394490 Deprecate passing a non-zero size to make-module
* module/ice-9/boot-9.scm (make-module): Issue a deprecation warning if
  users pass a non-zero size.
  (nested-define-module!, make-modules-in, beautify-user-module!)
  (resolve-interface, make-autoload-interface, %cond-expand-table):
* module/ice-9/popen.scm (port/pid-table):
* module/ice-9/session.scm (make-fold-modules):
* module/language/ecmascript/function.scm (*program-wrappers*):
* module/scripts/api-diff.scm (read-api-alist-file):
* module/srfi/srfi-10.scm (reader-ctors): Update callers.  Also remove
  some make-hash-table sizes.
2019-09-27 22:57:38 +02:00
Andy Wingo
f62e19bd10 (ice-9 null) also re-exports core aux syntax
* module/ice-9/null.scm: Re-export _, else, =>, and the ellipsis.
2019-09-27 22:57:38 +02:00
Andy Wingo
3be16199ab Avoid mutating arguments to resolve-interface
* module/ice-9/boot-9.scm (resolve-interface): This function used to
  mutate the #:hide argument, which results in terrorism if the value is
  a literal.
2019-09-27 22:57:38 +02:00
Andy Wingo
28318cba9c Remove "vm" tests
These tests are no longer useful.

* configure.ac:
* test-suite/Makefile.am: Remove mentions.
* test-suite/vm/Makefile.am:
* test-suite/vm/run-vm-tests.scm:
* test-suite/vm/t-basic-contructs.scm:
* test-suite/vm/t-call-cc.scm:
* test-suite/vm/t-catch.scm:
* test-suite/vm/t-closure.scm:
* test-suite/vm/t-closure2.scm:
* test-suite/vm/t-closure3.scm:
* test-suite/vm/t-closure4.scm:
* test-suite/vm/t-do-loop.scm:
* test-suite/vm/t-global-bindings.scm:
* test-suite/vm/t-literal-integers.scm:
* test-suite/vm/t-macros.scm:
* test-suite/vm/t-macros2.scm:
* test-suite/vm/t-map.scm:
* test-suite/vm/t-match.scm:
* test-suite/vm/t-mutual-toplevel-defines.scm:
* test-suite/vm/t-or.scm:
* test-suite/vm/t-proc-with-setter.scm:
* test-suite/vm/t-quasiquote.scm:
* test-suite/vm/t-records.scm:
* test-suite/vm/t-values.scm: Remove.
2019-09-27 22:57:38 +02:00
Andy Wingo
1c88d51c22 Adapt ftw.test for pending test-suite changes
* test-suite/tests/ftw.test ("file-system-fold"): Check "standalone"
  instead of "vm".
2019-09-27 22:57:38 +02:00
Andy Wingo
42c69ae669 Fix doc syntax error
* doc/ref/r6rs.texi (R6RS Incompatibilities): Fix syntax error.
2019-09-27 22:52:57 +02:00
Andy Wingo
714d0b9d9f Better R6RS compatibility
* module/ice-9/boot-9.scm (install-r6rs!): Also enable
  `hungry-eol-escapes'.
* doc/ref/r6rs.texi (R6RS Incompatibilities): Document lack of unicode
  escapes in symbols.
2019-09-27 14:08:02 +02:00
Andy Wingo
15bef73647 Add --r6rs NEWS
* NEWS: Add --r6rs news.
2019-09-25 22:10:57 +02:00
Andy Wingo
afcc22f639 Add --r6rs command-line option
* doc/ref/guile-invoke.texi (Command-line Options): Document --r6rs.
* doc/ref/r6rs.texi (R6RS Incompatibilities): Mention that --r6rs calls
  install-r6rs!.
* module/ice-9/command-line.scm (*usage*, compile-shell-switches):
  Implement --r6rs.
2019-09-25 22:08:12 +02:00
Andy Wingo
0bb980f120 New function: install-r6rs!
* doc/ref/r6rs.texi (R6RS Incompatibilities): Document install-r6rs!.
* module/ice-9/boot-9.scm (install-r6rs!): New function.
2019-09-25 22:06:38 +02:00
Andy Wingo
8fd7914f35 Update NEWS for 2.9.5
* NEWS: Update.
2019-09-19 15:43:01 +02:00
Andy Wingo
462782af86 Add documentation for else, =>, _, ... aux syntax
* doc/ref/api-macros.texi (Syntax Rules): Document aux syntax.
2019-09-19 15:42:57 +02:00
Andy Wingo
374c1e5807 Define top-level bindings for aux syntax: else, =>, _, ...
* 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.
2019-09-12 21:50:51 +02:00
Andy Wingo
4e89d0c061 Use "G_" as the conventional alias for gettext
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 _.
2019-09-12 21:50:35 +02:00
Andy Wingo
d1cf892880 Optimize fixnum or s64 -> f64 conversions
* libguile/intrinsics.c (scm_bootstrap_intrinsics):
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add "inexact"
  intrinsic.
* libguile/jit.c (compile_s64_to_f64): New compiler.
* libguile/vm-engine.c (s64->f64): New instruction.
* module/language/cps/effects-analysis.scm (heap-numbers-equal?):
* module/language/cps/reify-primitives.scm (compute-known-primitives):
* module/language/cps/slot-allocation.scm (compute-var-representations):
* module/language/cps/specialize-numbers.scm (fixnum->f64):
  (specialize-operations):
* module/language/cps/type-fold.scm (scm->f64, inexact):
* module/language/cps/types.scm (inexact, s64->f64):
* module/language/tree-il/cps-primitives.scm (exact->inexact):
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*effect-free-primitives*):
* module/system/vm/assembler.scm: Recognize exact->inexact as a
  primitive, and optimize it.  Add compiler support for new "inexact"
  and "s64->f64" primcalls.
2019-09-01 20:46:04 +02:00
Daniel Llorens
74f14562a6 Have disassemble-file accept an optional output port
* module/system/vm/disassembler.scm (disassemble-file): As stated.
2019-08-29 14:31:19 +02:00