diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-08-30 15:28:04 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-08-30 15:28:04 -0400 |
| commit | 77bd054713bc698a67ccc38a0b6fe07ffc161381 (patch) | |
| tree | 46274db054b50e9388751412e86dd2c5ce4d39f1 | |
| parent | 2187c15b54f8b2803586e0abdb7c7bc94daa83eb (diff) | |
Use 𝕩 as the error message in !𝕩
| -rw-r--r-- | docs/bqn.js | 2 | ||||
| -rw-r--r-- | docs/spec/primitive.html | 2 | ||||
| -rw-r--r-- | spec/primitive.md | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/docs/bqn.js b/docs/bqn.js index b2ce92be..ccef4a07 100644 --- a/docs/bqn.js +++ b/docs/bqn.js @@ -169,7 +169,7 @@ let run = (B,O,F,S,L,T,src,env) => { // Bytecode, Objects, Blocks, Bodies, Locat // Runtime let assertFn = pre => (x,w) => { - if (x!==1) throw {kind:pre, message:w}; return x; + if (x!==1) throw {kind:pre, message:has(w)?w:x}; return x; } let arr = (r,sh,fill) => {r.sh=sh;r.fill=fill;return r;} let list = (l,fill) => arr(l,[l.length],fill); diff --git a/docs/spec/primitive.html b/docs/spec/primitive.html index 128fd24f..f4cf08d9 100644 --- a/docs/spec/primitive.html +++ b/docs/spec/primitive.html @@ -66,7 +66,7 @@ </ul> <h2 id="other-provided-functionality"><a class="header" href="#other-provided-functionality">Other provided functionality</a></h2> <ul> -<li><strong>Assert</strong> (<code><span class='Function'>!</span></code>) causes an error if the argument is not <code><span class='Number'>1</span></code>. If <code><span class='Value'>𝕨</span></code> is provided, it gives a message to be associated with this error (which can be any value, not necessarily a string).</li> +<li><strong>Assert</strong> (<code><span class='Function'>!</span></code>) causes an error if <code><span class='Value'>𝕩</span></code> is not <code><span class='Number'>1</span></code>. The message associated with the error (which is not used by core BQN but might be shown to the user or used by system functions) is <code><span class='Value'>𝕨</span></code> if given and <code><span class='Value'>𝕩</span></code> otherwise. It can be any value, not just a string.</li> </ul> <ul> <li><strong>Catch</strong> (<code><span class='Modifier2'>⎊</span></code>) evaluates <code><span class='Function'>𝔽</span></code> on the arguments <code><span class='Value'>𝕨</span></code> (if present) and <code><span class='Value'>𝕩</span></code>. If <code><span class='Function'>𝔽</span></code> completes without error it returns the result, but if evaluation of <code><span class='Function'>𝔽</span></code> results in an error then the error is suppressed, and Catch evaluates <code><span class='Function'>𝔾</span></code> on the arguments and returns the result. Errors in <code><span class='Function'>𝔾</span></code> 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.</li> diff --git a/spec/primitive.md b/spec/primitive.md index 360c8629..37132ead 100644 --- a/spec/primitive.md +++ b/spec/primitive.md @@ -73,7 +73,7 @@ Inferred properties are specified in [their own document](inferred.md), not in t ## Other provided functionality -- **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). +- **Assert** (`!`) causes an error if `𝕩` is not `1`. The message associated with the error (which is not used by core BQN but might be shown to the user or used by system functions) is `𝕨` if given and `𝕩` otherwise. It can be any value, not just 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. |
