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
|
|
@ -8,17 +8,15 @@ program PortVars {
|
|||
money: fn() -> int
|
||||
price: fn(int) -> int
|
||||
}
|
||||
state PortvarsState {
|
||||
g_money: int = 40
|
||||
g_rate: int = 3
|
||||
var g_money: int = 40
|
||||
var g_rate: int = 3
|
||||
function priced(n: int) -> int {
|
||||
return n * g_rate
|
||||
}
|
||||
function priced(portvars_st: PortvarsState, n: int) -> int {
|
||||
return n * portvars_st.g_rate
|
||||
}
|
||||
bind Purse { money: PortvarsState.g_money, price: fn priced }
|
||||
entry (portvars_st: mut PortvarsState) {
|
||||
bind Purse { money: g_money, price: fn priced }
|
||||
entry {
|
||||
let a = Purse.money()
|
||||
portvars_st.g_money += 5
|
||||
g_money += 5
|
||||
print(`{a} {Purse.money()} {Purse.price(4)}`)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue