Allow binary operators to be used as lambdas (#385)

* Add operator lambdas

* Do not register anonymous functions as called functions

* Add tests

* Update CHANGELOG

* Update the docs

* Do not allow (..) to be used as a lambda

* Rename the function sum to any
This commit is contained in:
Gaith Hallak
2022-06-03 13:12:23 +04:00
committed by GitHub
parent b0e6418161
commit b3767071a8
6 changed files with 46 additions and 2 deletions
+1
View File
@@ -200,6 +200,7 @@ switch(f(x))
```c
Expr ::= '(' LamArgs ')' '=>' Block(Stmt) // Anonymous function (x) => x + 1
| '(' BinOp ')' // Operator lambda (+)
| 'if' '(' Expr ')' Expr 'else' Expr // If expression if(x < y) y else x
| Expr ':' Type // Type annotation 5 : int
| Expr BinOp Expr // Binary operator x + y