From fba3d225e7687f87f923dca6e7647bb30aa89025 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 1 Feb 2021 21:47:37 -0500 Subject: I don't make the problems, I just write them down. Okay I made them too --- docs/commentary/problems.html | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'docs/commentary/problems.html') diff --git a/docs/commentary/problems.html b/docs/commentary/problems.html index fbdd6eb5..d42a99b6 100644 --- a/docs/commentary/problems.html +++ b/docs/commentary/problems.html @@ -23,6 +23,7 @@

If you include multiple multi-line functions in what would otherwise be a one-liner, the flow in each function goes top to bottom but the functions are executed bottom to top. I think the fix here is to just say give your functions names and don't do this.

Control flow substitutes have awkward syntax

At the moment BQN has no control structures, instead preferring modifiers, function recursion, and headers. When working with pure functions, these can be better than control structures. For more imperative programming they're a lot worse. For example, it's natural to have two arguments for small structures, but that becomes unreadable for larger ones. However, predefined functions acting on functions can cover a lot of ground for the imperative programmer; see Control flow in BQN.

+

One particular sore point with Repeat (⍟) and Choose (β—Ά) is that the condition and action(s) always apply to the same set of arguments. Often you'd like them to apply to completely different things: this seems like the sort of thing that split compose F⊸G⟜H solved for trains, but here there's no such solution.

Hard to search part of an array or in a different order

This includes index-of-last, and searching starting at a particular index, when the desired result indices are to the array to be seached before it is modified. Given indices i into an array 𝕨 (for example βŒ½β†•β‰ π•¨ or a+↕b), this section can be searched with (iβˆΎβ‰ π•¨)⊏˜(iβŠπ•¨)βŠπ•©. But this is clunky and difficult for the implementation to optimize.

Subtraction, division, and span are backwards

@@ -60,6 +61,8 @@

List splicing is fiddly

It's common when manipulating text to want to replace a slice with a different slice with an unrelated length. Structural Under works well for this if the new slice has the same length but doesn't otherwise (an implementation could choose to support it, but only if the slice is extracted using two Drops, not Take). So in general the programmer has to cut off initial and final segments and join them to the new slice. If the new slice is computed from the old one it's much worse, as there will be duplication between the code to extract that slice and the other segments. The duplication can be avoided with Group using ∾F⌾(1βŠΈβŠ‘)(sβ€Ώeβ‹β†•βˆ˜β‰ )βŠΈβŠ”, but this is a lot of work and will execute slowly without some special support. In fact, everything here is liable to run slowly, making too many copies of the unmodified part of the stream.

Dyalog's solution here (and dzaima/BQN's) is Regex, which is a nice feature but also an entire second language to learn.

+

Can't always transfer ambivalence in tacit code

+

For example, there's no tacit equivalent of the old APL (NARS) ∘, which in explicit BQN is simply {𝕨𝔽𝔾𝕩}. Similarly, {(𝔽𝕨)𝔾𝕩} is missing. The contrast with Atop and Over, which work very smoothly, can be jarring and make it harder to get an intuition for what the code is doing.

Poor font support

Characters β₯ŠβˆΎβŸœβŽ‰βš‡Λœ and double-struck letters are either missing from many fonts or drawn strangely.

Choose and Repeat have order swapped

@@ -68,14 +71,16 @@

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

Blanket issue for glyphs that need work. Currently I find β₯ŠβŠβŠ‘βŠβŠ’β·βΌβŽ‰βš‡ to not be particularly good fits for what they describe.

+

Can't mix define and modify in multiple assignment

+

Say a is a pair and h isn't defined yet; how would you set h to the first element of a and change a to be just the second? hβ€Ώa↩a doesn't work because h isn't defined, so the best I have is h←@β‹„hβ€Ώa↩a. A heavier assignment syntax wouldn't break down; BQN could allow ⟨h←,aβŸ©β†©a but I don't think this merits special syntax.

Group doesn't include trailing empty groups

But there are workarounds, described in its documentation. dzaima has suggested allowing a single extra element in the index argument to specify the result shape. Another possibility is for the result prototype to be specified to allow overtaking.

+

Trains don't like monads

+

If you have the normal mix of monads and dyads you'll need a lot of parentheses and might end up abusing ⟜. Largely solved with the "nothing" glyph ·, which acts like J's Cap ([:) in a train, but still a minor frustration.

Under/bind combination is awkward

It's most common to use Under with dyadic structural functions in the form β€¦βŒΎ(i⊸F), for example where F is one of / or ↑. This is frustrating for two reasons: it requires parentheses, and it doesn't allow i to be computed tacitly. If there's no left argument then the modifier {π”½βŒΎ(π•¨βŠΈπ”Ύ)𝕩} can be more useful, but it doesn't cover some useful cases such as mask a ⊣⌾(u⊸/) b.

Axis ordering is big-endian

The most natural ordering for polynomial coefficients and base representations is little-endian, because it aligns element i of the list with power i of the argument or base. It also allows a forward scan instead of a reverse one. Array axes go the other way. However, there are advantages to this ordering as well. For example, it's common to act only on the first few axes, so having them at the beginning of the array is good (β‰ a ←→ βŠ‘βˆ˜β‰’a).

-

Trains don't like monads

-

If you have the normal mix of monads and dyads you'll need a lot of parentheses and might end up abusing ⟜. Largely solved with the "nothing" glyph ·, which acts like J's Cap ([:) in a train, but still a minor frustration.

Inverse is not fully specified

So it seems a bit strange to rely on it for core language features like /⁼. On the other hand, this is a good fit for ⋆⁼ since we are taking an arbitrary branch of a complex function that has many of them. I'm pretty sure it's impossible to solve the issue as stated but it might be possible to move to less hazardous constructs. Structural Under is a start.

Prefixes/Suffixes add depth and Windows doesn't

@@ -91,6 +96,8 @@

It's unergonomic, and also quadratic in a naive runtime. The problem of course is that tacit code can only combine up to two values at a time, while in explicit code, list notation combines any number of them. In a language less beholden to syntax, List would simply be a function with an arbitrary number of arguments and you'd be able to form trains with itβ€”although this does require distinguishing when it's used as a train versus as a plain function.

Must read the body to find headerless block's type

You have to scan for headers or double-struck names (and so does a compiler). A little inelegant, and difficult to describe in BNF. This can usually be fixed by adding a block header, except in the case of immediate modifiers: even an immediate modifier with a header can be made into a deferred modifier by adding a special name like 𝕨.

+

No one right way to check if a value is an array

+

The mathematical approach is 0<≑𝕩, which can be slow without runtime support, while the efficient approach is 0=β€’Type𝕩, which is ugly and uses a system function for something that has nothing at all to do with the system. These are minor flaws, but programmers shouldn't have to hesitate about which one they want to use.

Each block body has its own label

In a block with multiple bodies, the label (the self-name part of the header) refers to the entire block. However, there's no way to give only one label to the entire block. If you want to consistently use the same internal name, then you may have to write it many times. It's also a weird mismatch, conceptually.

Have to be careful about intermediate results with affine characters

@@ -115,7 +122,7 @@

Inputs to modifiers are called operands?

"Operand" is derived from "operator". "Modificand" would be better if it weren't both made up and hideous.

Converting a function expression to a subject is tricky

-

You can name it, you can write βŠ‘βŸ¨Expr⟩ or (Expr)Λ™0, and if it doesn't use special names you can write {Expr}. All of these are at least a little awkward in reasonable cases. Should there be a dedicated syntax? Note that going the other way, from subject to function, isn't too bad: the modifier {𝔽} does it.

+

You can name it, you can write βŠ‘βŸ¨Expr⟩ or (Expr)Λ™0, and if it doesn't use special names you can write {Expr}. All of these are at least a little awkward in reasonable cases. Should there be a dedicated syntax? Note that going the other way, from subject to function, isn't too bad: the modifier {𝔽} does it, as does β—‹βŠ’.

Scan ordering is weird

Scan moves along the array so that it uses results as left arguments, which is opposite to the usual right-to-left order of evaluation. But I think this is still better than scanning the array in reverse. You can always use Swap on the operand, or recover the APL scan ordering by doing a Reduce-Each on Prefixes.

Only errors in functions can be caught

-- cgit v1.2.3