This is an interpreted programming language made for fun. Not even close to finished.
let multiply = (a, b) =>
if (b > 0) {
a + multiply(a, b - 1)
} else {
0
}
print(multiply(2, 3))
- Ruby 2.5+
- Bundler
bundle
Call bin/clarke
with interpret
and the name of the file to run, e.g.
bin/clarke interpret samples/lambda.cke
Values:
3
"string"
true
false
Declaration and assignment:
let factor = 3
let factor = 3
factor = 4
Functions:
let double = (a) => 2 * a
let double = fun (a) { 2 * a }
Function calls:
print(123)
Conditionals:
if (b > 0) {
print("Bigger!")
} else {
print("Smaller!)
}
fun
: functionvar
: variabledef
: definitionlit
: literalref
: referenceparam
: parameter
- Allow mutually recursive functions
- Avoid
any
-typed expressions- Introduce well-typed function type: (type, …) => type
- Initialize all ivars
In no particular order:
- Comments
- Isolated scoping
- e.g.
iso fun a() { … }
which cannot access outer env
- e.g.
- More primitive types
- Chars
- Floats
- Null
- Compound types
- Arrays
- Structs
- Maps
- Ranges
- Sets
- Enumerable mixin
- Iterators
- If without else
- Modules
- Require all exported functions to be explicitly typed