From 07bf9008a0698d2ada09fe7db471adb349f1703c Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Fri, 16 Apr 2021 15:44:04 -0400 Subject: =?UTF-8?q?Specification=20for=20Catch=20(=E2=8E=8A)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/spec/evaluate.html | 1 + docs/spec/primitive.html | 3 +++ docs/spec/token.html | 2 +- spec/evaluate.md | 2 ++ spec/primitive.md | 2 ++ spec/token.md | 2 +- 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/spec/evaluate.html b/docs/spec/evaluate.html index 892aa7a5..9e221c53 100644 --- a/docs/spec/evaluate.html +++ b/docs/spec/evaluate.html @@ -7,6 +7,7 @@

Specification: BQN evaluation

This page describes the semantics of the code constructs whose grammar is given in grammar.md. The formation rules there are not named, and here they are identified by either the name of the term or by copying the rule entirely if there are several alternative productions.

Here we assume that the referent of each identifier, or equivalently the connections between identifiers, have been identified according to the scoping rules.

+

Errors described in this page are "evaluation errors" and can be caught by the Catch (⎊) modifier. If an error is caught, evaluation halts without attempting to complete any in-progress node, and is restarted as part of the execution of Catch.

Programs and blocks

The result of parsing a valid BQN program is a PROGRAM, and the program is run by evaluating this term.

A PROGRAM or BODY is a list of STMTs, which are evaluated in program order. A result is always required for BODY nodes, and sometimes for PROGRAM nodes (for example, when loaded with β€’Import). If any identifiers in the node's scope are exported, or any of its statements is an EXPORT, then the result is the namespace created in order to evaluate the node. If a result is required but the namespace case doesn't apply, then the last STMT node must be an EXPR and its result is used. The statement EXPR evaluates some APL code and possibly assigns the results, while nothing evaluates any subject or Derv terms it contains but discards the results. An EXPORT statement performs no action.

diff --git a/docs/spec/primitive.html b/docs/spec/primitive.html index 5b850b6a..a559a85e 100644 --- a/docs/spec/primitive.html +++ b/docs/spec/primitive.html @@ -68,6 +68,9 @@ +

Commentary on other primitives

As noted above, see reference.bqn for the authoritative definitions. Commentary here gives an overall description and highlights implementation subtleties and edge cases.

Combinators

diff --git a/docs/spec/token.html b/docs/spec/token.html index aee04486..8eb4bcee 100644 --- a/docs/spec/token.html +++ b/docs/spec/token.html @@ -35,7 +35,7 @@ Primitive 2-Modifier -βˆ˜β—‹βŠΈβŸœβŒΎβŠ˜β—ΆβŽ‰βš‡βŸ +βˆ˜β—‹βŠΈβŸœβŒΎβŠ˜β—ΆβŽ‰βš‡βŸβŽŠ Special name diff --git a/spec/evaluate.md b/spec/evaluate.md index 1ef6486a..e3cd2666 100644 --- a/spec/evaluate.md +++ b/spec/evaluate.md @@ -6,6 +6,8 @@ This page describes the semantics of the code constructs whose grammar is given Here we assume that the referent of each identifier, or equivalently the connections between identifiers, have been identified according to the [scoping rules](scope.md). +Errors described in this page are "evaluation errors" and can be caught by the Catch (`⎊`) modifier. If an error is caught, evaluation halts without attempting to complete any in-progress node, and is restarted as part of the execution of Catch. + ### Programs and blocks The result of parsing a valid BQN program is a `PROGRAM`, and the program is run by evaluating this term. diff --git a/spec/primitive.md b/spec/primitive.md index 386b0dcf..dc089cfa 100644 --- a/spec/primitive.md +++ b/spec/primitive.md @@ -75,6 +75,8 @@ Inferred properties are specified in [their own document](inferred.md), not in t - **Assert** (`!`) causes an error if the argument is not `1`. If `𝕨` is provided, it gives a message to be associated with this error (which can be any value, not necessarily a string). +- **Catch** (`⎊`) evaluates `𝔽` on the arguments `𝕨` (if present) and `𝕩`. If `𝔽` completes without error it returns the result, but if evaluation of `𝔽` results in an error then the error is suppressed, and Catch evaluates `𝔾` on the arguments and returns the result. Errors in `𝔾` are not caught. Catch only prevents evaluation errors, and not syntax errors: these are considered errors in the program as a whole rather than any particular part of it. + ## Commentary on other primitives As noted above, see [reference.bqn](reference.bqn) for the authoritative definitions. Commentary here gives an overall description and highlights implementation subtleties and edge cases. diff --git a/spec/token.md b/spec/token.md index 89d0d521..230f1f0b 100644 --- a/spec/token.md +++ b/spec/token.md @@ -23,7 +23,7 @@ Otherwise, a single character forms a token. Only the specified set of character | Null literal | `@` | Primitive Function | `+-Γ—Γ·β‹†βˆšβŒŠβŒˆ\|¬∧∨<>β‰ =≀β‰₯β‰‘β‰’βŠ£βŠ’β₯ŠβˆΎβ‰β†‘β†“β†•Β«Β»βŒ½β‰/β‹β’βŠβŠ‘βŠβŠ’βˆŠβ·βŠ”!` | Primitive 1-Modifier | `` Λ™ΛœΛ˜Β¨βŒœβΌΒ΄Λ` `` -| Primitive 2-Modifier | `βˆ˜β—‹βŠΈβŸœβŒΎβŠ˜β—ΆβŽ‰βš‡βŸ` +| Primitive 2-Modifier | `βˆ˜β—‹βŠΈβŸœβŒΎβŠ˜β—ΆβŽ‰βš‡βŸβŽŠ` | Special name | `π•¨π•©π•—π•˜π•€π•Žπ•π”½π”Ύπ•Š` | Punctuation | `←⇐↩→(){}βŸ¨βŸ©β€Ώβ‹„,.` and newline -- cgit v1.2.3