diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-03-08 22:01:00 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-03-08 22:01:00 -0500 |
| commit | 0486ab226b132d3ae5919eb041f5a4888dd31d36 (patch) | |
| tree | bd7796299f0ea7f2f288c39ae0888c6467ab8665 /docs/commentary | |
| parent | f55d2fae6505f094c4017d4ba6a29ac2042927ff (diff) | |
Allowing negative indices is less safe
Diffstat (limited to 'docs/commentary')
| -rw-r--r-- | docs/commentary/problems.html | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/docs/commentary/problems.html b/docs/commentary/problems.html index fc90bc3f..2c7c0964 100644 --- a/docs/commentary/problems.html +++ b/docs/commentary/problems.html @@ -88,6 +88,8 @@ <h3 id="at-which-scope-does-a-block-function-belong">At which scope does a block function belong?</h3> <p>As a general principle, a programmer should make choices in one part of a program that constrain other parts of the program most tightly. This is a weak principle, but often it doesn't conflict with any other preferences and can be followed for free. For example it's usually best to define a variable in the smallest possible scope, so the reader knows it isn't used outside that scope. The same principle applies to blocks, but there is another conflicting principle: placing the block in a broader scope guarantees it won't access the variables in narrower ones. There's no position that will tell the reader, for example, that a function only uses variables local to itself and that it's only used within one particular scope.</p> <p>This is an issue with any lexically-scoped language; it's unlikely BQN can solve it. On the other hand, I'm surprised I've never seen any discussion of such a universal issue.</p> +<h3 id="negative-indices-dont-fail-by-default">Negative indices don't fail by default</h3> +<p>The typical case when selecting from an array is that a negative index doesn't make sense, and you'd prefer it to give an error. But negative indices are pretty useful in some contexts so BQN trades safety for convenience. Manually checking that indices are non-negative is easier than full range checking, but the issue is that you have to do it manually at all.</p> <h3 id="rankdepth-negative-zero">Rank/Depth negative zero</h3> <p>A positive operand to Rank indicates the cell rank, so positive zero means to act on 0-cells. A negative operand indicates the frame length, so negative zero should act on the entire array. But it can't because it's equal to positive zero. Similar issue with Depth. Positive/negative is not really the right way to encode the frame/cell distinction, but it's convenient. Fortunately ∞ can be used in place of negative zero, but there can still be problems if the rank is computed.</p> <h3 id="tacit-code-cant-build-lists-easily">Tacit code can't build lists easily</h3> |
