From 4c6e15275efbc976ff72cbfd7db74756d8afa25f Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 12 Sep 2022 21:34:06 -0400 Subject: Editing --- commentary/overload.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'commentary/overload.md') diff --git a/commentary/overload.md b/commentary/overload.md index bb2dee41..58b8eee2 100644 --- a/commentary/overload.md +++ b/commentary/overload.md @@ -34,7 +34,7 @@ If that was all, it would hardly be worth mentioning. A more significant family There are examples outside the array world that I find worse than anything in BQN. `+` for string catenation. This no longer obeys commutativity or distributivity: it's not safe to rearrange `a + b` to `b + a` or `(a+b)*c` to `(a*c)+(b*c)` in languages that do this! NumPy and MATLAB allow a boolean array to be used as an index, performing filtering. This one doesn't obey the rule that the length of `a[b]` is the length of `b`, or any other length-based rules really. -Sometimes what seems like an extension can be unified into a single more general primitive. For example, APL has [scalar extension](https://aplwiki.com/wiki/Scalar_extension) to allow you to add, say, a scalar to a list in `1 + 2‿3‿4`. J and BQN use the more general [leading axis agreement](../doc/leading.md#leading-axis-agreement), which has this extension as a special case (although incidentally, BQN removes some unprincipled extension of list-like functions like Reverse to rank-0 arguments). Character arithmetic can also be viewed in this way considering numbers and characters to be pairs of "characterness" 0 or 1, and a numeric value. +Sometimes what seems like an extension can be unified into a single more general primitive. For example, APL has [scalar extension](https://aplwiki.com/wiki/Scalar_extension) to allow you to add, say, a scalar to a list in `1 + 2‿3‿4`. J and BQN use the more general [leading axis agreement](../doc/leading.md#leading-axis-agreement), which has this extension as a special case (although incidentally, BQN removes some unprincipled extension of list-like functions like Reverse to rank-0 arguments). Character arithmetic can also be viewed in this way, by considering numbers and characters to be pairs of "characterness" 0 or 1, and a numeric value. I think many primitive pairs, such as `-`, `⋆`, `«`, `⥊`, and `⍉`, fall into this category too. These can all be described as a general dyadic function, and a monadic case that comes from a default left argument (sometimes dependent on the right argument: it's `(=𝕩)-1` for `⍉`). The primitive `⋈` is so tight it might be considered a fully compatible overload, returning a list of all arguments. Such primitive pairs can sometimes be used ambivalently in simple ways (`⋆⁼` is pretty nice), but more often the usefulness is just that it's easier to think about each pair as one thing rather than two. It's just two views of the same idea. @@ -50,7 +50,7 @@ And then we reach the cases that I think of as purely mnemonic, in that they the The examples are all primitive pairs now, and that's because BQN doesn't use mnemonic overloading within primitives (APL does occasionally, such as `○`, and J has a number of kitchen-sink primitives like `;.` and `p:`). And of course, there's a level after this where there's just no connection. BQN glyphs aren't chosen randomly, so the reason that this happens is that both functions are separately a fit for the glyph. But as I said at the beginning, in a language not tied to primitive glyphs there's no reason to do this. -Here's my list of how the primitives fit together. The table fits into rows, but there are no hard distinctions; I've tried to put the more coherent pairs of functions closer the the beginning of each row. +Here's my list of how the primitives fit together. The table fits into rows, but there are no hard distinctions; I've tried to put the more coherent pairs of functions closer to the beginning of each row. Tier | Primitive pairs -----------|----------------- -- cgit v1.2.3