You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 14, 2020. It is now read-only.
Non-local control transfer in the form of exceptions is a feature generally expected by most programmers in any high-level language. Non-local control transfer is useful because it prevents programmers from having to explicitly thread error handling functions through code. The fact try handlers are dynamically bound is useful because it allows programmers to catch exceptions in code they did not write.
I propose the addition of an exceptions system to gherkin that follows mostly from Clojure/JVM and a little from MacLisp/Common Lisp - the main difference between them being that catch tags in Common Lisp are not classes, but can be any object.
This hybrid systems allows us to:
provide an exception mechanism without necessarily implementing user-defined types or heirarchies
admit user-defined types as catch tags, if we implement them, without breaking existing code
throw
(throw <tag-expr> <result-expr?>)
<tag-expr> is evaluated, and when throw is called, the corresponding try handler with the dynamically-nearest, =<tag-expr> is invoked.
<result-expr?> is an optional expression that defaults to nil. It is evaluated at throw-time and passed to the dynamically-nearest try handler and bound to <result-form-name>.
catch
(try <exprs> <catch-clause> <finally-clause?>)
<exprs> are evaluated, and if now exceptions are thrown, the value of the last is returned.
<catch-clause> is (catch <tag-expr> <result-expr-name> <catch-exprs>). If an exception with a matching <tag-expr> is thrown inside <exprs>, <result-expr-name> is bound to the throw expression's <result-expr?> and <catch-exprs> are evaluated.
<finally-clause?> is optional and of the format (finaly <finaly-exprs>). Before returning, normally or abnormally, any finally exprs will be evaluated for their side effects.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Non-local control transfer in the form of exceptions is a feature generally expected by most programmers in any high-level language. Non-local control transfer is useful because it prevents programmers from having to explicitly thread error handling functions through code. The fact
try
handlers are dynamically bound is useful because it allows programmers tocatch
exceptions in code they did not write.I propose the addition of an exceptions system to gherkin that follows mostly from Clojure/JVM and a little from MacLisp/Common Lisp - the main difference between them being that catch tags in Common Lisp are not classes, but can be any object.
This hybrid systems allows us to:
throw
(throw <tag-expr> <result-expr?>)
<tag-expr>
is evaluated, and when throw is called, the correspondingtry
handler with the dynamically-nearest,=
<tag-expr>
is invoked.<result-expr?>
is an optional expression that defaults to nil. It is evaluated at throw-time and passed to the dynamically-nearesttry
handler and bound to<result-form-name>
.catch
(try <exprs> <catch-clause> <finally-clause?>)
<exprs>
are evaluated, and if now exceptions are thrown, the value of the last is returned.<catch-clause>
is(catch <tag-expr> <result-expr-name> <catch-exprs>)
. If an exception with a matching<tag-expr>
is thrown inside<exprs>
,<result-expr-name>
is bound to the throw expression's<result-expr?>
and<catch-exprs>
are evaluated.<finally-clause?>
is optional and of the format(finaly <finaly-exprs>)
. Before returning, normally or abnormally, any finally exprs will be evaluated for their side effects.The text was updated successfully, but these errors were encountered: