diff options
author | Andy Wingo <wingo@pobox.com> | 2010-01-31 12:35:19 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-02-26 11:56:02 +0100 |
commit | e10cf6b9c7e54c79db4de74584f1b0b65847d4fc (patch) | |
tree | 3df9ed5f6b52af3b0ffd5605e2f8834705bb589c /libguile/deprecated.c | |
parent | d296431516dbf14535fc6eaba551fede19c09772 (diff) | |
download | guile-e10cf6b9c7e54c79db4de74584f1b0b65847d4fc.tar.gz |
deprecate lazy-catch
* libguile/deprecated.h:
* libguile/deprecated.c (scm_internal_lazy_catch, scm_lazy_catch):
Deprecate, and print out a nasty warning that people should change to
with-throw-handler.
* libguile/throw.h:
* libguile/throw.c (scm_c_with_throw_handler): Deprecate the use of the
lazy_catch_p argument, printing out a nasty warning if someone
actually passes 1 as that argument. The combination of the pre-unwind
and post-unwind handlers should be sufficient.
* test-suite/tests/exceptions.test: Remove lazy-catch tests, as they are
deprecated. Two of them fail:
* throw/catch: effect of lazy-catch unwinding on throw to another key
* throw/catch: repeat of previous test but with lazy-catch
Hopefully people are not depending on this behavior, and the warning is
sufficiently nasty for people to switch. We will see.
* test-suite/tests/eval.test ("promises"): Use with-throw-handler
instead of lazy-catch.
* doc/ref/api-debug.texi:
* doc/ref/api-control.texi: Update to remove references to lazy-catch,
folding in the useful bits to with-throw-handler.
Diffstat (limited to 'libguile/deprecated.c')
-rw-r--r-- | libguile/deprecated.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libguile/deprecated.c b/libguile/deprecated.c index 54f0055b3..95f6f4662 100644 --- a/libguile/deprecated.c +++ b/libguile/deprecated.c @@ -1816,6 +1816,56 @@ scm_i_subr_p (SCM x) } + +SCM +scm_internal_lazy_catch (SCM tag, scm_t_catch_body body, void *body_data, scm_t_catch_handler handler, void *handler_data) +{ + scm_c_issue_deprecation_warning + ("`scm_internal_lazy_catch' is no longer supported. Instead this call will\n" + "dispatch to `scm_c_with_throw_handler'. Your handler will be invoked from\n" + "within the dynamic context of the corresponding `throw'.\n" + "\nTHIS COULD CHANGE YOUR PROGRAM'S BEHAVIOR.\n\n" + "Please modify your program to use `scm_c_with_throw_handler' directly,\n" + "and adapt it (if necessary) to expect to be within the dynamic context\n" + "of the throw."); + return scm_c_with_throw_handler (tag, body, body_data, handler, handler_data, 0); +} + +SCM_DEFINE (scm_lazy_catch, "lazy-catch", 3, 0, 0, + (SCM key, SCM thunk, SCM handler), + "This behaves exactly like @code{catch}, except that it does\n" + "not unwind the stack before invoking @var{handler}.\n" + "If the @var{handler} procedure returns normally, Guile\n" + "rethrows the same exception again to the next innermost catch,\n" + "lazy-catch or throw handler. If the @var{handler} exits\n" + "non-locally, that exit determines the continuation.") +#define FUNC_NAME s_scm_lazy_catch +{ + struct scm_body_thunk_data c; + + SCM_ASSERT (scm_is_symbol (key) || scm_is_eq (key, SCM_BOOL_T), + key, SCM_ARG1, FUNC_NAME); + + c.tag = key; + c.body_proc = thunk; + + scm_c_issue_deprecation_warning + ("`lazy-catch' is no longer supported. Instead this call will dispatch\n" + "to `with-throw-handler'. Your handler will be invoked from within the\n" + "dynamic context of the corresponding `throw'.\n" + "\nTHIS COULD CHANGE YOUR PROGRAM'S BEHAVIOR.\n\n" + "Please modify your program to use `with-throw-handler' directly, and\n" + "adapt it (if necessary) to expect to be within the dynamic context of\n" + "the throw."); + + return scm_c_with_throw_handler (key, + scm_body_thunk, &c, + scm_handle_by_proc, &handler, 0); +} +#undef FUNC_NAME + + + void scm_i_init_deprecated () { |