From 558804cbb1a365c3fae4c97b56e6603fe93cf028 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 14 Oct 2021 17:00:28 -0400 Subject: Remove indications that BQN might add tolerant comparison; it won't --- commentary/problems.md | 10 +++------- doc/match.md | 2 +- docs/commentary/problems.html | 20 ++------------------ docs/doc/match.html | 4 ++-- spec/reference.bqn | 2 -- 5 files changed, 8 insertions(+), 30 deletions(-) diff --git a/commentary/problems.md b/commentary/problems.md index bf9ab494..4167ba27 100644 --- a/commentary/problems.md +++ b/commentary/problems.md @@ -44,13 +44,6 @@ Only `⍋⍒` use array ordering rather than just array equality or numeric orde ### Nothing (`Β·`) interacts strangely with Before and After Since `𝕨F⊸G𝕩` is `(F𝕨)G𝕩` and `𝕨F⟜G𝕩` is `𝕨F G𝕩` in the dyadic case, we might expect these to devolve to `G𝕩` and `F G𝕩` when `𝕨` is not present. Not so: instead `𝕩` is substituted for the missing `𝕨`. And Before and After are also the main places where a programmer might try to use `𝕨` as an operand, which doesn't work either (the right way is the train `𝕨F⊒`). It's also a little strange that `v F˜·` is `Β·`, while `Β·F v` is `F v`. -### Comparison tolerance -Kind of necessary for practical programming, but how should it be invoked or controlled? A system variable like `βŽ•CT`? Per-primitive control? Both? Which primitives should use it? - -Definitely | Maybe | Definitely not ------------|------------|--------------- -`=≠≀β‰₯<>` | `β‰‘β‰’βŠβŠ’βˆŠβ·\|` | `⍋⍒` - ### No access to fast high-precision sum Fold has a specific order of application, which must be used for `` +` ``. But other orders can be both faster and more precise (in typical cases) by enabling greater parallelism. Generally ties into the question of providing precision control for a program: it could be fixed by a flag that enables BQN to optimize as long as the results will be at least as precise (relative to the same program in infinite precision) as the spec. @@ -74,6 +67,9 @@ In Choose, the selector goes on the left; in Repeat, the count goes on the right ### Group doesn't include trailing empty groups A length can now be specified either in an extra element in any rank-1 component of `𝕨`, or by overtaking, since the result's fill element is an empty group. However, it still seems like it would be pretty easy to end up with a length error when a program using Group encounters unexpected data. It's a fundamental safety-convenience tradeoff, though, because specifying a length has to take more code in the general case. +### Tolerant comparison +APL has it and BQN doesn't; after some experience it seems this causes few problems, and the extra effort required for the algorithms that do need it is negligible (anyway, it's better to be aware when your code relies on imprecise equality). APL and J also tolerate inexact indices and lengths, which is also something that could be supported. + ### Index Of privileges the first match It could be more sound to look at all matches, but using just the first one is too convenient. J has an index-of-last function; in BQN you have to reverse the left argument and then do arithmetic: `β‰ βˆ˜βŠ£-1+⌽⊸⊐`. diff --git a/doc/match.md b/doc/match.md index e85b8c59..14ff8ffb 100644 --- a/doc/match.md +++ b/doc/match.md @@ -27,7 +27,7 @@ Starting with the easiest rules, values with different types are never equal to ⟨'a', +, 3⟩ = ⟨-⟜», '+', 3Λ™βŸ© -Two characters are equal when they have the same code point. Numeric equality depends on the number system in use, but probably works about how you expect. If you're coming from APL, note that current BQN implementations don't employ comparison tolerance. To see if two floats are roughly equal you'll need to write a tolerant comparison yourself, but how often do you really need to do this? +Two characters are equal when they have the same code point. Numeric equality depends on the number system in use, but probably works about how you expect. If you're coming from APL, note that BQN doesn't use comparison tolerance. To see if two floats are roughly equal you'll need to write a tolerant comparison yourself, but how often do you really need to do this? 'x' = "wxyz" diff --git a/docs/commentary/problems.html b/docs/commentary/problems.html index 16bbcac4..e2feae77 100644 --- a/docs/commentary/problems.html +++ b/docs/commentary/problems.html @@ -32,24 +32,6 @@

Only ⍋⍒ use array ordering rather than just array equality or numeric ordering. Getting at the actual ordering to just compare two arrays is more difficult than it should be (but not that difficult: β₯ŠβŠΈβ‹βŒΎ< is TAO ≀).

Nothing (Β·) interacts strangely with Before and After

Since 𝕨F⊸G𝕩 is (F𝕨)G𝕩 and 𝕨F⟜G𝕩 is 𝕨F G𝕩 in the dyadic case, we might expect these to devolve to G𝕩 and F G𝕩 when 𝕨 is not present. Not so: instead 𝕩 is substituted for the missing 𝕨. And Before and After are also the main places where a programmer might try to use 𝕨 as an operand, which doesn't work either (the right way is the train 𝕨F⊒). It's also a little strange that v F˜· is Β·, while Β·F v is F v.

-

Comparison tolerance

-

Kind of necessary for practical programming, but how should it be invoked or controlled? A system variable like βŽ•CT? Per-primitive control? Both? Which primitives should use it?

- - - - - - - - - - - - - - - -
DefinitelyMaybeDefinitely not
=≠≀β‰₯<>β‰‘β‰’βŠβŠ’βˆŠβ·|⍋⍒

No access to fast high-precision sum

Fold has a specific order of application, which must be used for +`. But other orders can be both faster and more precise (in typical cases) by enabling greater parallelism. Generally ties into the question of providing precision control for a program: it could be fixed by a flag that enables BQN to optimize as long as the results will be at least as precise (relative to the same program in infinite precision) as the spec.

High-rank array notation

@@ -65,6 +47,8 @@

In Choose, the selector goes on the left; in Repeat, the count goes on the right. Could be a strength in some contexts, since you can change Repeat-as-If to Choose if you don't like the ordering, but maybe a language that forces the programmer to make semantic decisions for syntactic reasons is not providing the greatest of services.

Group doesn't include trailing empty groups

A length can now be specified either in an extra element in any rank-1 component of 𝕨, or by overtaking, since the result's fill element is an empty group. However, it still seems like it would be pretty easy to end up with a length error when a program using Group encounters unexpected data. It's a fundamental safety-convenience tradeoff, though, because specifying a length has to take more code in the general case.

+

Tolerant comparison

+

APL has it and BQN doesn't; after some experience it seems this causes few problems, and the extra effort required for the algorithms that do need it is negligible (anyway, it's better to be aware when your code relies on imprecise equality). APL and J also tolerate inexact indices and lengths, which is also something that could be supported.

Index Of privileges the first match

It could be more sound to look at all matches, but using just the first one is too convenient. J has an index-of-last function; in BQN you have to reverse the left argument and then do arithmetic: β‰ βˆ˜βŠ£-1+⌽⊸⊐.

Glyphs that aren't great

diff --git a/docs/doc/match.html b/docs/doc/match.html index b162bd3b..1e73afb8 100644 --- a/docs/doc/match.html +++ b/docs/doc/match.html @@ -30,7 +30,7 @@ ↗️
    ⟨'a', +, 3⟩ = ⟨-⟜», '+', 3Λ™βŸ©
 ⟨ 0 0 0 ⟩
 
-

Two characters are equal when they have the same code point. Numeric equality depends on the number system in use, but probably works about how you expect. If you're coming from APL, note that current BQN implementations don't employ comparison tolerance. To see if two floats are roughly equal you'll need to write a tolerant comparison yourself, but how often do you really need to do this?

+

Two characters are equal when they have the same code point. Numeric equality depends on the number system in use, but probably works about how you expect. If you're coming from APL, note that BQN doesn't use comparison tolerance. To see if two floats are roughly equal you'll need to write a tolerant comparison yourself, but how often do you really need to do this?

↗️
    'x' = "wxyz"
 ⟨ 0 1 0 0 ⟩
 
@@ -57,7 +57,7 @@
 

Block equality

The final point above about block instances is subtler. An instance of a block function or modifier is mutable, meaning that its behavior can change over the course of a program. Consider the following two functions:

↗️
    Fβ€ΏG ← { a←10 β‹„ {a+𝕩}β€Ώ{a↩𝕩} }
-⟨ *function* *function* ⟩
+⟨ (function block) (function block) ⟩
 
     F 5   # One result
 15
diff --git a/spec/reference.bqn b/spec/reference.bqn
index ba0e0570..f37e184e 100644
--- a/spec/reference.bqn
+++ b/spec/reference.bqn
@@ -2,8 +2,6 @@
 # limited initial functionality. Implementations are designed to be
 # simple and not fast.
 
-# Not yet included: complex numbers or comparison tolerance.
-
 # In some cases an operation is defined with limited functionality at
 # first and later expanded. For convenience, rather than renaming these
 # limited versions, every primitive use refers to the most recent
-- 
cgit v1.2.3