Settlang is a statically typed programming language that expresses mutability by whether variables have setters.
Visit Playground (watasuke102.github.io/settlang) to try on the playground!
See /examples
for more.
#*
Settlang minimal example
*#
fn accumulator(self: i64, e: i64) -> i64 {
# just return added value
ret self + e
}
fn randomize() -> i64 {
ret random(0, 100)
}
# function named `main` is entrypoint
fn main() -> i64 {
# they have 'setter' function, so mutable
let sum: i64 | accumulator = 0
let rnd: i64 | randomize = 0
for i in 0..10 {
rnd.set() # call setter of rnd
print("{}", rnd) # print value
if i != 9 {
print(", ")
}
sum.set(sum, rnd) # call setter of sum
}
println("")
ret sum
}
Dual-licensed; MIT (LICENSE-MIT
or The MIT License – Open Source Initiative) or MIT SUSHI-WARE LICENSE (LICENSE-MIT_SUSHI.md
)