diff options
| author | eunhhu <[email protected]> | 2026-09-30 15:23:30 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-30 15:23:30 +0100 |
| commit | b8e3faaf1a3766591d31e6c5411c9e4fcc59a7a4 (patch) | |
| tree | 3474ee41486141e0144a4899081a8780f69ced05 /examples | |
| parent | be1122a2e8bc720bd9473c130255eba46389c883 (diff) | |
| download | aup-b8e3faaf1a3766591d31e6c5411c9e4fcc59a7a4.tar.gz aup-b8e3faaf1a3766591d31e6c5411c9e4fcc59a7a4.zip | |
Give aup a bool: true and false, and conditions that take one
A condition was any number, non-zero being true: done was a number field,
a view showed 1 for true, and done + 1 was no type error. Now bool is its
own type (Pure 016, module format v6):
- true and false; comparisons, text comparisons, has and ! && || give a
bool. Bools are equal or not; they are no numbers and have no order.
- if, conditional expressions, require, where (folds, walks, filtered
tables) take a bool. Given a number, the diagnostic says how to make
one: "if takes a bool, not a number: compare it, as in n != 0".
- Bool states (state on = false), record fields (done = false), message,
output and argument fields (ok: bool), lets, views and columns.
Interpolation writes true or false. A list is not keyed by a bool.
- The examples' flags are bools (charge's holding, toggle's visible,
tasks' done).
Checks: 20 bool diagnostics, a form using bools everywhere, an app whose
every output shows true and false (states, items, views, columns, text)
and whose replacement turns a number into a bool and back. Models hold
bools and compare them strictly: Python's True == 1 no longer hides a 1
where a true belongs. Generated programs are typed, numbers and bools.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/charge.aup | 6 | ||||
| -rw-r--r-- | examples/tasks.aup | 2 | ||||
| -rw-r--r-- | examples/toggle.aup | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/examples/charge.aup b/examples/charge.aup index d483b8f..11b6756 100644 --- a/examples/charge.aup +++ b/examples/charge.aup @@ -1,5 +1,5 @@ # Hold Space to charge a jump; gravity and the floor are authored here. -state holding = 0 +state holding = false state charge = 0 state y = 240 state velocity = 0 @@ -10,7 +10,7 @@ view amount = charge on jump.down { if y >= 240 { - holding = 1 + holding = true charge = 0 } } @@ -18,7 +18,7 @@ on jump.down { on jump.up { if holding { velocity = -(160 + charge * 300) - holding = 0 + holding = false charge = 0 } } diff --git a/examples/tasks.aup b/examples/tasks.aup index 065f649..8240348 100644 --- a/examples/tasks.aup +++ b/examples/tasks.aup @@ -5,7 +5,7 @@ use words record Task { title: text - done = 0 + done = false } state tasks: list of Task diff --git a/examples/toggle.aup b/examples/toggle.aup index 39417cc..d5cf5d9 100644 --- a/examples/toggle.aup +++ b/examples/toggle.aup @@ -1,10 +1,10 @@ # Space toggles visibility; Right arrow moves a position that wraps. -state visible = 1 +state visible = true state position = 120 input toggle = key Space input move = key ArrowRight view marker_x = position -view marker_radius = visible * 24 +view marker_radius = if visible { 24 } else { 0 } view tile_x = position - 24 view value = visible |
