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

9 commits

Author SHA1 Message Date
Ludovic Courtès
d47061db23 exceptions: Export constructor and predicate for '&quit-exception'.
* module/ice-9/exceptions.scm: Re-export '&quit-exception' and export
'make-quit-exception' and 'quit-exception?'.
(quit-exception?): New procedure.
2020-01-18 23:33:01 +01:00
Andy Wingo
8068994ba8 Re-implement `guard'
* module/ice-9/exceptions.scm (guard): Add guard definition that
  re-propagates from original continuation, runs consequents in tail
  position in guard continuation, and doesn't rewind the stack.
* module/srfi/srfi-34.scm:
* module/rnrs/exceptions.scm (guard): Re-export from (ice-9
  exceptions).
2020-01-10 21:42:26 +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
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
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
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