Message Send
Unary
Let's look at nested function call from C like lang:
It reads from the inside out or from right to left.
Let's remove parenthesis
And now invert, to make it readable:
Now we got niva syntax!
Some ML languages use pipe operators to achieve the same readability42 |> foobar |> bar |> foo
So every call has a receiver that receive "message" 1 inc factorial
receiver <- message1 <- message2
Here is a more complex example:
There are three kinds of messages.
You are already familiar with unary, it has one arg(it's receiver).
But what if we need more args?
Keyword
//This is the most common way to send messages
What about sending messages with arguments? 1 add 2
okay, but what if we have more args1 addMany 2 3 4 add 2
this is pretty unreadable, so we need to distinguish each arg1 add: 2
widget widgh: 250 height: 250
If you need to compose keyword msgs inside each other use (), also you can put args on new lines:
Do you find this readable?
In C like languages there is a concept of calling functions with named arguments...
So in niva name of the function and name of the arguments are the same
// TODO пикча из презентации пхаро
Binary
Binary messages is a pretty common syntax:
But its not operators, its still a messages for receiver: receiver + arg
unary always evaluate first, 1 inc inc + 4 dec
-> (1 inc inc) + (4 dec)
-> 3 + 3
-> 6
Here are some examples that became looks like DSL because of that rule:
Send keyword to keyword
1 from: 2 to: 3
Is