daul is a language that transpiles to Lua. It aims to simplify the use of functional-style code by eliminating the distinction between statements and expressions.
Daul | Generated/Equivalent Lua code |
Tables: // Use [] instead of {}
val arr = [ 1, 2, 3 ]
// Use "key:" instead of "[key] ="
val tbl = [ "arr": arr ]
val zeroindexed = [ 0: 1, 2, 3 ]; |
local arr={1,2,3};
local tbl={["arr"]=arr};
local zeroindexed={[0]=1,2,3}; |
Statements and blocks: // Example TODO |
-- Example TODO |
Constant variables: var x = 0
x = 1
val y = 2
y = 3 |
Compiler error:
|
Functions: val f1 = \arg1, arg2 -> {
print(arg1)
arg1 + arg2
}
// Block can be omitted for a single expression
val f2 = \x -> 1+x
// Arguments can be omitted when there are none
val f3 = \[ "a": "b" ]
val f4 = \{
print("f4")
f3()
} |
local f1 = (function(arg1,arg2)
print(arg1);
return (arg1+arg2);
end);
local f2 = (function(x)
return (1+x);
end);
local f3 = (function()
return {["a"]="b"};
end);
local f4 = (function()
print("f4");
return f3();
end); |