Add compiler support for calling async functions directly with `await fn(args)` syntax, automatically translating to `await fn.call(args)`. Introduce `create_merge` Makefile target for merging Wren source files. Include new `apps/generator.wren` source code generator using OpenRouter API, `apps/phonebook.wren` CLI phonebook with SQLite backend, and `apps/minitut.md` Wren tutorial reference. Update `example/await_demo.wren` with parameterized async functions, nested awaits, and expression usage. Fix JSON parsing in `example/openrouter_demo.wren` to strip markdown code fences. Document new await syntax in `manual/api/scheduler.html`.
18 lines
486 B
JavaScript
Vendored
18 lines
486 B
JavaScript
Vendored
// retoor <retoor@molodetz.nl>
|
|
|
|
import "scheduler" for Scheduler, Future
|
|
|
|
var double = async { |x| x * 2 }
|
|
var triple = async { |x| x * 3 }
|
|
|
|
System.print(await double(5)) // expect: 10
|
|
System.print(await double.call(5)) // expect: 10
|
|
|
|
var f1 = double.call(10)
|
|
var f2 = triple.call(10)
|
|
System.print(await f1) // expect: 20
|
|
System.print(await f2) // expect: 30
|
|
|
|
System.print(await double(await triple.call(2))) // expect: 12
|
|
System.print(await double.call(await triple(2))) // expect: 12
|