From 9afbc503ef4957e005c1df732aa4f9ba310f659c Mon Sep 17 00:00:00 2001 From: "Ioanna M. Dimitriou H" Date: Tue, 13 Dec 2022 15:21:42 +0100 Subject: [PATCH 1/4] Adds explanatory prose related to `delegate`. This resolves the last three so far unaddressed `todo::` sections: - Add prose explaining try-delegate's jump. - Adds prose and intuition for delegating exception handlers. + Also a minor modification to the prose of catching exception handlers, that somewhat reduces calling the administrative instruction by its identifier (CAUGHTadm) in the prose. --- document/core/exec/runtime.rst | 11 +++++------ document/core/syntax/instructions.rst | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/document/core/exec/runtime.rst b/document/core/exec/runtime.rst index fb1ee00d..3e3f3148 100644 --- a/document/core/exec/runtime.rst +++ b/document/core/exec/runtime.rst @@ -542,21 +542,20 @@ to their associated branch *targets*, each of which is expressed syntactically a :ref:`instructions ` possibly following a :ref:`tag address `. If there is no :ref:`tag address `, the instructions of that handler clause correspond to a |CATCHALL| clause. -.. todo:: - Add prose for delegating handlers. +Delegating handlers start with the identifier |DELEGATEadm| and carry a label index, +indicating the outer block in which any caught exceptions will be thrown (delegated to). .. math:: \begin{array}{llllll} \production{(handler)} & \handler &::=& \CATCHadm\{\tagaddr^?~\instr^\ast\}^\ast &|& \DELEGATEadm\{l\} \end{array} -Intuitively, for each handler clause :math:`\{\tagaddr^?~\instr^\ast\}` of a |CATCHadm|, :math:`\instr^\ast` is the *continuation* to execute +Intuitively, for each handler clause :math:`\{\tagaddr^?~\instr^\ast\}` of a catching handler, :math:`\instr^\ast` is the *continuation* to execute when the handler catches a thrown exception with tag |tagaddr|, or for any exception, when a handler clause specifies no tag address. -In that case, the exception is handled by the exception handler |CATCHadm|. +In that case, the exception is handled by the exception handler. If this list of targets is empty, or if the tag address of the thrown exception is not in any of the handler's clauses and there is no |CATCHALL| clause, then the exception will be rethrown. -.. todo:: - Add prose with intuition on delegating handlers. +Delegating handlers can be thought of a "break to the :math:`l`th label on exception", where :math:`l` is the delegating handler's label index. .. _exec-expand: diff --git a/document/core/syntax/instructions.rst b/document/core/syntax/instructions.rst index 1fcaf896..d8b4c89b 100644 --- a/document/core/syntax/instructions.rst +++ b/document/core/syntax/instructions.rst @@ -686,8 +686,8 @@ In case of |BLOCK| or |IF| it is a *forward jump*, resuming execution after the matching |END|. In case of |LOOP| it is a *backward jump* to the beginning of the loop. -.. todo:: - Add prose for try-delegate's jump. +In case of |TRY|--|DELEGATE| catching an exception, it is a *forward jump*, +throwing the caught exception *before* the matching |END|. .. note:: This enforces *structured control flow*. From a03b5f4f10944ac4f89f254e36d31099dc23756e Mon Sep 17 00:00:00 2001 From: Ioanna M Dimitriou H <9728696+ioannad@users.noreply.github.com> Date: Fri, 23 Dec 2022 19:50:12 +0100 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Andreas Rossberg --- document/core/syntax/instructions.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/document/core/syntax/instructions.rst b/document/core/syntax/instructions.rst index d8b4c89b..706e2993 100644 --- a/document/core/syntax/instructions.rst +++ b/document/core/syntax/instructions.rst @@ -686,8 +686,8 @@ In case of |BLOCK| or |IF| it is a *forward jump*, resuming execution after the matching |END|. In case of |LOOP| it is a *backward jump* to the beginning of the loop. -In case of |TRY|--|DELEGATE| catching an exception, it is a *forward jump*, -throwing the caught exception *before* the matching |END|. +When |TRY|--|DELEGATE| handles an exception, it also behaves similar to a forward jump, +effectively rethrowing the caught exception right before the matching |END|. .. note:: This enforces *structured control flow*. From 160338e903b22637aaf338bfee0c83fa39de5064 Mon Sep 17 00:00:00 2001 From: "Ioanna M. Dimitriou H" Date: Wed, 15 Feb 2023 18:38:54 +0100 Subject: [PATCH 3/4] Reverting these changes here, will be added to #226 shortly --- document/core/exec/runtime.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/document/core/exec/runtime.rst b/document/core/exec/runtime.rst index 8d0c17b9..cf457398 100644 --- a/document/core/exec/runtime.rst +++ b/document/core/exec/runtime.rst @@ -539,21 +539,21 @@ to their associated branch *targets*, each of which is expressed syntactically a :ref:`instructions ` possibly following a :ref:`tag address `. If there is no :ref:`tag address `, the instructions of that handler clause correspond to a |CATCHALL| clause. -Delegating handlers start with the identifier |DELEGATEadm| and carry a label index, -indicating the outer block in which any caught exceptions will be thrown (delegated to). +.. todo:: + Add prose for delegating handlers. .. math:: \begin{array}{llllll} \production{handler} & \handler &::=& \CATCHadm\{\tagaddr^?~\instr^\ast\}^\ast &|& \DELEGATEadm\{l\} \end{array} -Intuitively, for each handler clause :math:`\{\tagaddr^?~\instr^\ast\}` of a catching handler, :math:`\instr^\ast` is the *continuation* to execute +Intuitively, for each handler clause :math:`\{\tagaddr^?~\instr^\ast\}` of a |CATCHadm|, :math:`\instr^\ast` is the *continuation* to execute when the handler catches a thrown exception with tag |tagaddr|, or for any exception, when a handler clause specifies no tag address. -In that case, the exception is handled by the exception handler. +In that case, the exception is handled by the exception handler |CATCHadm|. If this list of targets is empty, or if the tag address of the thrown exception is not in any of the handler's clauses and there is no |CATCHALL| clause, then the exception will be rethrown. -Delegating handlers can be thought of a "break to the :math:`l`th label on exception", where :math:`l` is the delegating handler's label index. - +.. todo:: + Add prose with intuition on delegating handlers. .. _exec-expand: From e8256a5a3307155309666140d254f86c2b581a2c Mon Sep 17 00:00:00 2001 From: "Ioanna M. Dimitriou H" Date: Wed, 15 Feb 2023 18:53:21 +0100 Subject: [PATCH 4/4] fixed accidental line deletion --- document/core/exec/runtime.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/document/core/exec/runtime.rst b/document/core/exec/runtime.rst index cf457398..a48cadab 100644 --- a/document/core/exec/runtime.rst +++ b/document/core/exec/runtime.rst @@ -555,6 +555,7 @@ If this list of targets is empty, or if the tag address of the thrown exception .. todo:: Add prose with intuition on delegating handlers. + .. _exec-expand: Conventions