let complex0 = re: 2, im: 3
let complex1 = re: 3, im: 5
module Complex {
def (re, im)::plus(re, im) = re: this.re + re, im: this.im + im
def (re, im)::minus(re, im) = re: this.re - re, im: this.im - im
}
// without using the module (plain importing)
complex0::Complex.plus(complex1)
// using the module
using Complex
complex0::plus(complex1)
Design
:: is designated as an operator that creates a reference function. complex0::Complex.plus or the other variant binds creates an invocable function that is bounded to complex0 as the receiver.
However, there will a new AST, OptimizedBoundedInvocation that is basically like invocation but without creating a reference, and eliminates the overhead.
using is stolen from C#/C++ syntax, this up to debate. However, what remains essential is that there is a way to call create a reference function without the need to call the module.
Types will become named tuples, a possible syntax is as follows.
Design
::
is designated as an operator that creates a reference function.complex0::Complex.plus
or the other variant binds creates an invocable function that is bounded tocomplex0
as the receiver.OptimizedBoundedInvocation
that is basically like invocation but without creating a reference, and eliminates the overhead.using
is stolen from C#/C++ syntax, this up to debate. However, what remains essential is that there is a way to call create a reference function without the need to call the module.