why is BQN syntax not limiting
As you may know or not, in BQN functions can have only 1 or 2 argument(s). The syntax is as follows:
F x
w F x
The function gets only right parameter when it is monadic (first one), and gets left and right argument when it is dyadic(second one). One can think of it as a "limitation", but it really is not.
I will first compare C-style syntax to LISP and then prove my point by the same intuition. For a quick introduction if you are not familiar with LISP, the name comes from "List Processing". As the name suggests, it brings a lots of facilities to work (read, manipulate) linked lists. But it's more than that! Even its syntax is bunch of linked lists. List items are represented inside parentheses, so it's full of ( ) s.
here's a typical LISP code for calculating delta.
(defun delta (a b c)
(- (* b b) (* 4 a c)))
Here's the equivalent C-style code:
int delta(int a, int b, int c) {
return b*b - 4*a*c;
}
For the equation
(delta 1 5 6)
And in C:
delta(1, 5, 6);
A random programmer not familiar with LISP might say that the LISP version is wierd and ambiguous. Well I'd argue that this is because of unfamiliarity. in the C-style version, if I move curly brackets, it will become:
(delta 1, 5, 6);
remove the ; and ,
(delta 1 5 6)
Well, as you saw, it's not that ambiguous!! To your surprise, It would be seen so much simpler than OO-C-style code. In general, in OO languages, functions have at least 2 ways of calling:
function(a, b); // normall function call
a.function(b); // method call syntax
But in LISP, there is one and only one universal way.
(function a b)
It's becoming interesting, right? Back to our original debate, when you consider 2 styles of calling function (i.e. normal call and method call) it would be easily comparable to what BQN currently has.
Function(x);
Function x
w.Function(x);
w Function x
A smart reader may ask: "what will you do with more than 2 arguments"? It is not much hard, you should make tuple.
delta(1, 5, 6);
delta [1, 5, 6]
or can separate then into 2 pars
1 delta [2, 3]
[1, 2] delta 3
A sharp-eye reader may ask what will you do with function that have 0 arguments? Remeber when defining a 0 argument function in C one can do this:
float random() { ...
float random( void ) { ...
The same appies in BQN. You can pass empty.
Random •
the • means empty. Or you can pass "seed", which is more realistic in this case.
Random 0.32
Wanna random number between 2 numbers?
[1, 10] Random 0.32
Wanna send response to http request?
Express.js
res.send("hey")
BQN
res Send "hey"
wanna set status code too?
res Send [200, "hey"]
This argument might not convince you at first. But hope it gave you some insights.
BQN's context-free grammar