feat(lang): 27.3 - a reducer on a table's row: reducer T in S.table on A, @Target, Row<T>, @RowVerb, @Column
An action names one row of a ludic.base Table<T> by its handle, in a field marked @Target, and `reducer Deer in Herd.deer on Spook(r: mut Row<Deer>, n: Noise, a: Spook)` runs once, for that row alone (the table may sit down a path, S.w.tab). The drain resolves the handle (tb_row) and hands the reducer a Row<T> - new in ludic.base: tb, row, h, rec - that the queue keeps, one per row reducer, filled in place, so a targeted action allocates nothing; a stale handle runs nothing, and LUDIC_ACTIONS_LOG=1 prints a line for it (@alloc_ok). Row reducers order among an action's by their state's name, then the table's path. Checked at compile time (actions_rows.ludic): the row reaches r.rec and r.h only - r.tb / r.row refused, the view never assigned, stored, copied or handed on except to a @RowVerb (a function of the record's own module taking Row<T> first; any other function taking a row is refused); a field marked @Column (a table column mirrors it) is not written through r.rec; only the module owning the state declares a row reducer; one @Target, an int, per action; the states between the row and the action are read. `mut` is allowed on a Row<T> parameter. ludic schema's code section gains row_reducers (record, table, state, action, target, predicted, net, module, at) and row_verbs (name, record, module, at), and every action its target; row reducers are left out of `reducers`. ludic deps and ludic-lsp name a row reducer `reducer Deer in Herd.deer on Spook`. vocab: @Target, @Column, @RowVerb; docs/language pages; LANGUAGE.md "A reducer on a row"; examples actions/rows and ten rejects; test.ludic feat, reject and schema cases (not run); changes/row-reducers.md. Reseeded; bootstrap-cfree fixpoint holds (307497 lines); Maroon Lake's `ludic build --check` is clean against this tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d22abae476
commit
ab0b84b87e
37 changed files with 125923 additions and 110956 deletions
|
|
@ -262,13 +262,33 @@ function dp_pad(s: pointer, n: int) -> pointer {
|
|||
}
|
||||
# a function as its source names it: a reducer is `reducer Bag on PickUp`, not its symbol
|
||||
function dp_fn_name(n: pointer) -> pointer {
|
||||
if not s_starts(n, "ludic_reduce__") { return n }
|
||||
if not s_starts(n, "ludic_reduce__") and not s_starts(n, "ludic_rowred__") { return n }
|
||||
let rest = n[14 .. slen(n)]
|
||||
for i in 0 .. slen(rest) - 1 {
|
||||
if rest[i] == '_' and rest[i + 1] == '_' { return `reducer {rest[i + 2 .. slen(rest)]} on {rest[0 .. i]}` }
|
||||
if rest[i] == '_' and rest[i + 1] == '_' { return `reducer {dp_row_name(rest[i + 2 .. slen(rest)])} on {rest[0 .. i]}` }
|
||||
}
|
||||
return n
|
||||
}
|
||||
# 27.3: a row reducer's symbol says `Deer__in__Herd__deer` for `Deer in Herd.deer`
|
||||
function dp_row_name(s: pointer) -> pointer {
|
||||
var out = ""
|
||||
var seen = false
|
||||
var i = 0
|
||||
while i < slen(s) {
|
||||
if not seen and i + 6 <= slen(s) and s[i .. i + 6] == "__in__" {
|
||||
out = out + " in "
|
||||
seen = true
|
||||
i += 6
|
||||
} else if seen and i + 2 <= slen(s) and s[i .. i + 2] == "__" {
|
||||
out = out + "."
|
||||
i += 2
|
||||
} else {
|
||||
out = out + s[i .. i + 1]
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
function dp_own(k: int) -> bool { return dp_pkg[k] == 0 }
|
||||
# an edge the numbers count: between two of the program's own modules
|
||||
function dp_counted(e: int) -> bool { return dp_own(dp_ef[e]) and dp_own(dp_et[e]) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue