diff options
| author | eunhhu <[email protected]> | 2026-09-25 15:14:08 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-25 15:14:08 +0100 |
| commit | c298c2eec0b7ec0fcdacb8f661a9da3c184d2960 (patch) | |
| tree | affe490db2b070f0b064bbb9bf5ade49d45a9293 /examples/tasks.aup | |
| parent | 91aa0afcd34cff345f1f7293d82fec7d00082d8b (diff) | |
| download | aup-c298c2eec0b7ec0fcdacb8f661a9da3c184d2960.tar.gz aup-c298c2eec0b7ec0fcdacb8f661a9da3c184d2960.zip | |
Add fns and libraries
fn name(params) = value declares one expression, inlined where it is
called: arguments are computed once onto the stack and the body reads them
with PICK, so a fn costs no runtime call and keeps Pure's bound on work.
Parameters take any kind of value; recursion is a compile error.
use name reads name.aup beside the source or from AUP_PATH. A library
declares only fns and uses, sees only its parameters, and is called as
name.fn(...). Diagnostics now carry the file they are in, and the
compiler takes a loader so that sources come from the host.
examples/words.aup is such a library; examples/tasks.aup uses it and still
matches its reference model.
Diffstat (limited to 'examples/tasks.aup')
| -rw-r--r-- | examples/tasks.aup | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/examples/tasks.aup b/examples/tasks.aup index 38d06ef..065f649 100644 --- a/examples/tasks.aup +++ b/examples/tasks.aup @@ -1,6 +1,8 @@ # A task list. The runtime owns the list: the index always names an item, # stays on it when items are inserted or removed before it, stops at the # ends, and a failed event leaves the list as it was. +use words + record Task { title: text done = 0 @@ -40,10 +42,11 @@ view position = at.position view current = if tasks.count > 0 { at.title } else { "(empty)" } view status = if tasks.count > 0 { "{at.position + 1}/{tasks.count}" } else { "empty" } view finished = at.done # no value while the list is empty +view summary = words.counted(tasks.count, "task", "tasks") # One row per task. A surface computes only the rows it shows. view board = each task in tasks { title = task.title - mark = if task.done { "x" } else { " " } + mark = words.check(task.done) here = task.position == at.position } |
