wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3eda72e8c2
commit
5ffe50ed02
463 changed files with 72045 additions and 67421 deletions
|
|
@ -9,14 +9,12 @@ program FunctionValues {
|
|||
function double(x: int) -> int { return x * 2 }
|
||||
function square(x: int) -> int { return x * x }
|
||||
function half(x: float) -> float { return x / 2.0 }
|
||||
state FunctionvaluesState {
|
||||
op: fn(int) -> int = null
|
||||
}
|
||||
var op: fn(int) -> int = null
|
||||
function run_with(f: fn(int) -> int, v: int) -> int { return f(v) }
|
||||
function pass_on(f: fn(float) -> float) -> fn(float) -> float { return f }
|
||||
entry (functionvalues_st: mut FunctionvaluesState) {
|
||||
functionvalues_st.op = fn double
|
||||
print(functionvalues_st.op(21))
|
||||
entry {
|
||||
op = fn double
|
||||
print(op(21))
|
||||
let ops = new []fn(int) -> int
|
||||
push(ops, fn double)
|
||||
push(ops, fn square)
|
||||
|
|
@ -28,6 +26,6 @@ program FunctionValues {
|
|||
print(run_with(fn square, 9))
|
||||
let h = pass_on(fn half)
|
||||
print(h(3.0))
|
||||
if functionvalues_st.op != null { print(1) }
|
||||
if op != null { print(1) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue