Hello, World
printl"Hello, World!"Prelude imports and top-level execution in one line.
Examples
These examples are selected from executable fixtures. Dewy and µDewy are related but distinct source languages, so every example is labeled.
printl"Hello, World!"Prelude imports and top-level execution in one line.
let values:array<int64> = [10 20 12]
let i:int64 = 0
let total:int64 = 0
loop i <? values.length {
total += values[i]
i += 1
}Flow-proven bounds make the indexed access valid.
let point = [
x = 3
y = 4
sum = () => x + y
]
let value = point.sumStructural fields and methods with object-local lookup.
let text = "café 👨👩👧👦"
let family = text[5]
let count = family.lengthIndex and length operate on extended grapheme clusters.
let total:int64 = 0
loop i in 0,2..10 {
total += i
}
loop i in 5,3..0 {
total += i
}A second anchor establishes either a positive or negative step without a separate range constructor.
let total:int64 = 0
loop i in 0..2 and j in 10..20 {
total += i
}Iterator conditions compose directly with logical operators; and stops when either iterator is exhausted.
let value:int64|none = choose(true)
if value is? int64 {
return value + 2
}
return 0A type test narrows the optional value for the successful branch without an assertion or forced unwrap.
let choose = (():>int64 => 20)
& ((x:int64):>int64 => x)
let answer = choose() + choose(22)& combines ordinary function values, and each call selects the implementation matching its arguments.
let add = (x:int64 y:int64=2):>int64 =>
x + y
let answer = add(40)
let same = add(39 y=3)Parameters can have lazy defaults, while named arguments make overrides and reordered calls explicit.
from p"lib.dewy" import (answer add Number)
import p"lib.dewy" as library
let value:library.Number = answer
let result = add(value)Selective and namespaced imports share file-relative path values and one type system across modules.
let fib = (n:int):>int => {
if n <=? 1 { return n }
return fib(n - 1) + fib(n - 2)
}Compile the bootstrap subset entirely in the browser.
udewy -c \
udewy/bootstrap/main.udewyThe µDewy compiler is itself implemented in µDewy.
The repository also contains backend tests, web and SDL demos, games, data structures, graphics experiments, and older design examples. Some files under the top-level examples/ directory describe planned language behavior rather than the current compiler.