|
|
|
|
|
by johan_felisaz
1672 days ago
|
|
Genuine question, what would be the idiomatic way of doing an impure operation multiple times in J/APL ? (e.g. if writing an interpreter loop) I was wondering if it's doable without the while. and other constructs (which honestly feel like plugged artificially in J, even syntax wise) |
|
When designing BQN I embraced the limited nature of array primitives, so that most primitives can only implement efficiently parallelizable programs and none of them can perform infinite loops. Flip this around and you get guarantees: if you create a function by composing primitives you know it will halt, and if you avoid using modifiers in complicated ways it's easy to prove good sequential and parallel bounds on the runtime.[0] Although BQN has no tail recursion (J also doesn't; Dyalog does), it's possible to implement loop functionality that uses only logarithmic stack space in the number of iterations, with low overhead (I just measured 30ns/iteration in CBQN for a simple incrementing loop).[1]
[0] https://mlochbaum.github.io/BQN/doc/primitive.html
[1] https://mlochbaum.github.io/BQN/doc/control.html#low-stack-v...