ludic.base's Queue<T> carries a QueueTag (its name and pending count): queue_new(name), q_push(q, v), q_drain(q), q_clear(q) take no BaseState, and core_undrained(tags) names the given queues still holding facts. A reducer on a package's state can now call that package's verbs (wallet_earn(wallet_st, n)). ludic migrate state --prune (ludicc --migrate-prune) takes out each state parameter a function no longer uses, nor anything it calls, and the argument that fills it - including an argument for a parameter the callee has dropped, which is taken out before the call is checked, so a generic's T is told by the argument that says it. A reducer keeps its state. --dry-run now counts the edits it would make. Every package was moved with it: 608 base_st parameters and their arguments, 1889 edits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| tests | ||
| index.ludic | ||
| package.ludic | ||
| README.md | ||
| wallet.ludic | ||
ludic.wallet
Money carried, in whole units: earned, spent only when it is there, lost when a cost happens
anyway, and every change reported. Uses ludic.base and nothing
else. Prices, reputation and what a thing costs are the game's; the wallet only holds the money.
import "ludic.wallet"
No ports: the wallet asks the world nothing.
API
wallet_money(), wallet_can(n) |
what is there, and whether n is |
wallet_earn(n) |
add |
wallet_spend(n) -> bool |
only what is there: false, and nothing spent, when it is not |
wallet_lose(n) |
a cost that happens whether or not it can be paid (a rescue); never below zero |
wallet_set(n) |
exactly n (a starting purse, a correction, the network's word) |
wallet_changes() -> Queue<MoneyChanged> |
the facts: { before, after }, one per change |
wallet_system() -> System |
"wallet", PH_COMMIT: reset, and its save section (wallet_save, wallet_load) |
Tests
ludic build packages/ludic.wallet/tests/wallet_test.ludic --headless -o /tmp/wallet_test && /tmp/wallet_test