An idea to import functions as operators, but only allowed inside a sym block. This makes it possible to experiment with syntax and create an ad-hoc DSL, without colliding with other operators or affecting how it is used in other projects.
use math::{add as ."+"., mul_scalar as ."*"., mul_comp as ."**".}
sym {[2] + [4, 5] * 3 + [6, 7] ** [8, 9]}
Unary and list arguments could be supported. No newline is needed after an expression.
use io::println as ">>".
use math::min as ."◁".. // Expand as array
a := 2
b := 3
c := 4
d := 5
// println(min([2, b, c]))
// println(d)
sym {>> 2 ◁ b ◁ c >> d}
One could bind variables in scope and function calls to arguments of an operator.
a := []
use std::push as (mut a)"<<"some(.)
sym {
<< 1 << 2 << 3
}
// prints `[some(1), some(2), some(3)]`
println(a)
Operators works as language sugar that rewrites meta data before passing it to lifetime/type checker and constructing the AST.
An idea to import functions as operators, but only allowed inside a
sym
block. This makes it possible to experiment with syntax and create an ad-hoc DSL, without colliding with other operators or affecting how it is used in other projects.The order of import defines the precedence.
With optional namespaces this could look like this:
Unary and list arguments could be supported. No newline is needed after an expression.
One could bind variables in scope and function calls to arguments of an operator.
Operators works as language sugar that rewrites meta data before passing it to lifetime/type checker and constructing the AST.