fix(lang): the action drain is the program's; --check runs every check a build makes; a registry key named count is refused; name lookups are tables
- the function that calls every reducer (and the action queue) is written in the program's own file: in the first action's file it belonged to that module, depended on every module with a reducer, and joined a game's modules into one 69-module cycle (examples/actions/modules and a ludic deps case hold it); the state instances, the queue and the reducers make no deps edges - ludicc --check / ludic build --check lower the program too and write nothing, so the code writer's refusals are in it: a bind to a function that is gone, an unknown name (and the checker now refuses fn <missing> itself); rejects bind_missing_fn, unknown_name, registry_count_key - def R count is refused: its constant would be PREFIX_COUNT, the registry's size - a file's module, package, trust and numbers-float are tables, and from the check on the lookups of functions, enums, records, globals and externs are too (tagged enums kept as a list): Maroon Lake's check-only build went from about 20 s to 7 s including lowering, its IR from about 2 minutes to under 10 s; duplicate declarations are found by table, not a pair of loops - threads.ludic's pool check gives each call a little work, so a busy machine cannot run them all on the caller before a worker wakes (it failed one run in three under load) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2fdefa6040
commit
8cf4b3fed6
24 changed files with 67169 additions and 64398 deletions
4
examples/actions/mods/acts/index.ludic
Normal file
4
examples/actions/mods/acts/index.ludic
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# acts/index.ludic - the actions, in a module that uses nothing: dispatching or declaring them makes
|
||||
# no module depend on the modules whose reducers handle them
|
||||
module acts uses
|
||||
export action PickUp { item: int }
|
||||
5
examples/actions/mods/bag/index.ludic
Normal file
5
examples/actions/mods/bag/index.ludic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# bag/index.ludic - the bag's state and its reducer; it uses acts for the action's type
|
||||
module bag uses acts
|
||||
export state Bag { items: []int = new []int }
|
||||
reducer Bag on PickUp(b: mut Bag, a: PickUp) { push(b.items, a.item) }
|
||||
export function bag_count(b: Bag) -> int { return len(b.items) }
|
||||
12
examples/actions/modules.ludic
Normal file
12
examples/actions/modules.ludic
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# modules.ludic - 0.R: an action declared in one module and reduced in another; the drain that calls
|
||||
# every reducer is the program's own, so acts does not come to depend on bag (ludic deps: no cycle)
|
||||
import "mods/acts"
|
||||
import "mods/bag"
|
||||
program ActionModules {
|
||||
entry (b: Bag) {
|
||||
dispatch PickUp { item: 4 }
|
||||
dispatch PickUp { item: 5 }
|
||||
drain_actions()
|
||||
print(bag_count(b))
|
||||
}
|
||||
}
|
||||
|
|
@ -23,8 +23,13 @@ program Threads {
|
|||
Sync.unlock(threads_st.lock)
|
||||
}
|
||||
|
||||
# remember which calls ran on a pool thread
|
||||
function placed(i: int, out: words) -> void { if Job.is_worker() { out[i] = 1 } else { out[i] = 0 } }
|
||||
# remember which calls ran on a pool thread - each with a little work in it, so on a busy machine
|
||||
# the calling thread cannot claim every index before a worker wakes
|
||||
function placed(i: int, out: words) -> void {
|
||||
var spin = 0
|
||||
for k in 0 .. 2000 { spin = spin + k % 7 }
|
||||
if Job.is_worker() { out[i] = 1 + spin * 0 } else { out[i] = spin * 0 }
|
||||
}
|
||||
|
||||
entry (threads_st: mut ThreadsState) {
|
||||
if Sync.cpu_count() >= 1 { print(1) }
|
||||
|
|
|
|||
6
examples/rejected/bind_missing_fn.ludic
Normal file
6
examples/rejected/bind_missing_fn.ludic
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# a port bound to a function that is not there: refused by a check-only build too
|
||||
program BindMissingFn {
|
||||
port Clock { now: fn() -> int }
|
||||
bind Clock { now: fn no_such_clock }
|
||||
entry { print(Clock.now()) }
|
||||
}
|
||||
8
examples/rejected/registry_count_key.ludic
Normal file
8
examples/rejected/registry_count_key.ludic
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# a def keyed `count` would be TL_COUNT, the registry's own size
|
||||
program RegistryCountKey {
|
||||
property Tool { key: string = "", n: int = 0 }
|
||||
registry Tools of Tool as TL
|
||||
def Tools count { n: 1 }
|
||||
def Tools axe { n: 2 }
|
||||
entry { print(TL_COUNT) }
|
||||
}
|
||||
4
examples/rejected/unknown_name.ludic
Normal file
4
examples/rejected/unknown_name.ludic
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# a name that is nothing: refused by a check-only build as by a build
|
||||
program UnknownName {
|
||||
entry { print(no_such_name + 1) }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue