`ludic help` ended with a section titled "contributing to the toolchain itself", listing bootstrap, reseed, docs-gen and release tasks. None of that is available to someone who installed the language — those tasks need the repository — so the shipped tool was advertising work its user cannot do, in a namespace they have to read past to find `new` and `run`. The tasks move to a second program, dev.ludic -> bin/ludic-dev, built from a checkout and excluded from every release artifact. `ludic` keeps the project and package commands and nothing else; `ludic dev …` now explains where the tasks went instead of failing as an unknown command. What this shook out: the two programs share prelude/build/project/pkg, so the helpers each had accreted in whichever file first needed them — cc(), ensure_ludicc, the string functions, title_case, cmd_version — moved to where both can see them. The argument-shift indirection added for the `dev` namespace is gone with the namespace, so commands read argv directly again. `ludic-dev test` asserts the split rather than trusting it: the staged install must build a project, and `ludic dev build` there must fail while naming ludic-dev. install.sh keeps building older tags, whose bootstrap goes through main.ludic. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
38 lines
1.5 KiB
Text
38 lines
1.5 KiB
Text
# reason.ludic — LC1 reason-carrying teardown. One @OnDespawn hook, but it knows
|
|
# *why* the entity is ending: `reason: r` binds an EndReason the compiler passes
|
|
# at each teardown site. An in-world `despawn` passes EndReason.Despawned; program
|
|
# shutdown passes EndReason.Quit (every still-live entity's hook fires at exit — no
|
|
# silent deaths). The body branches on the reason, exactly as Unreal's
|
|
# EndPlay(reason) / Erlang's terminate(Reason) do.
|
|
#
|
|
# Running it prints: 503 1009
|
|
# 503 Enemy A despawned in-world (Despawned): drop its loot, 3 + 500
|
|
# 1009 Enemy B outlived the run; at quit (Quit) it skips loot, 9 + 1000
|
|
#
|
|
# bin/ludic-dev game-build bin/ludicc examples/lang/reason.ludic /tmp/reason
|
|
# /tmp/reason </dev/null
|
|
program Reasons {
|
|
property Health { hp: int = 0 }
|
|
property Loot { gold: int = 0 }
|
|
model Enemy { Health, Loot }
|
|
|
|
@OnDespawn(Enemy, reason: r) handler Clean {
|
|
match r {
|
|
EndReason.Quit => { print(Health.hp + 1000) } # app closing — don't bother dropping loot
|
|
_ => { print(Loot.gold + 500) } # died in-world — drop the loot
|
|
}
|
|
}
|
|
|
|
handler Seed phase Start {
|
|
spawn Enemy { Health { hp: 7 }, Loot { gold: 3 } } # A
|
|
spawn Enemy { Health { hp: 9 }, Loot { gold: 4 } } # B
|
|
}
|
|
|
|
handler Run phase Render {
|
|
var first = 0
|
|
for (e) in query [Health] {
|
|
if first == 0 { despawn self(); first = 1 } # despawn A -> Despawned -> 3 + 500 = 503
|
|
}
|
|
quit() # B survives -> Quit -> 9 + 1000 = 1009
|
|
}
|
|
}
|