aboutsummaryrefslogtreecommitdiff
path: root/commentary
diff options
context:
space:
mode:
Diffstat (limited to 'commentary')
-rw-r--r--commentary/overload.md4
1 files changed, 2 insertions, 2 deletions
diff --git a/commentary/overload.md b/commentary/overload.md
index a64f0fcb..0adcc25d 100644
--- a/commentary/overload.md
+++ b/commentary/overload.md
@@ -24,7 +24,7 @@ APL isn't really a "one obvious way to do it" in the sense that Python is, but i
This means that something like the number 1 can mean many things, like an index or a count or a boolean, and the replicate function `/` might mean repeating or filtering. It's overloading, but it's a very consistent form because the mathematical description of what's going on in either case is the same. But it's not the only way—some statically-typed languages like Java and Haskell prefer to declare classes to split things up, so that the type system can check things for the user. An extreme example is a system that takes user input but needs to sanitize or escape it before passing it to certain functions. The APL way would be to represent both unsafe and safe input as strings, which is obviously dangerous.
-However, the advantage of representing everything in a consistent format is that methods that work on one thing tend to work on many things. Want to reverse a string? It's just `⌽`. Defining boolean negation `¬𝕩` more generally as `1-𝕩` makes some arithmetic more obvious, for example `+´¬l` is `(≠l)-+´l`. And connections can be made at a higher level too: if you learn a rule like `a⊏b⊏c` ←→ `a⊏(b⊏c)`, that applies for every meaning of `⊏`. As long as `a` and `b` are flat arrays, that is, which highlights a conflict between this sort of compatible overloading and other sorts of extension.
+However, the advantage of representing everything in a consistent format is that methods that work on one thing tend to work on many things. Want to reverse a string? It's just `⌽`. Defining boolean negation `¬𝕩` more generally as `1-𝕩` makes some arithmetic more obvious, for example `+´¬l` is `(≠l)-+´l`. And connections can be made at a higher level too: if you learn a rule like `a⊏b⊏c` ←→ `(a⊏b)⊏c`, that applies for every meaning of `⊏`. As long as `a` and `b` are flat arrays, that is, which highlights a conflict between this sort of compatible overloading and other sorts of extension.
## Extensions
@@ -36,7 +36,7 @@ There are examples outside the array world that I find worse than anything in BQ
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.
-I think many primitive pairs, such as `-`, `⋆`, `«`, `⥊`, and `⍉`, fall into this category too. Primitives like can be described as a general dyadic function, and a monadic case that comes from a default left argument (sometimes dependent on the left 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.
+I think many primitive pairs, such as `-`, `⋆`, `«`, `⥊`, and `⍉`, fall into this category too. Primitives like can 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.
## Mnemonic overloading