Tasks & Sections

Tasks & Sections

Tasks are Thorn's functions. Sections are Thorn's answer to code organisation — a lighter alternative to classes that does not force object-oriented patterns.


Tasks

task add(x, y) {
    send x + y
}

task greet(name) {
    write(v"hello {name}")
}

result = add(3, 4)
greet("world")

Tasks with no send implicitly return void.

Sections

section networking {
    task connect(url) { }
    task disconnect() { }
}
networking.connect("pawnet://ABC12")

Visibility

section.global networking { }
section.parent database { }
section(ui, main) networking { }

Entry Point

section main {
    task run() {
        write("hello")
    }
}
if (start) {
    main()
}

Concurrency

spawn(fetchData(url))
out = spawn(process(data))
write(out) # waits if needed

Full Language Reference →