ludic/examples/modules/visible.ludic
Orkuncakilkaya 19fcf60599 wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run
ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic
  1804 vars into 126 states, 64 into lets; 23498 edits in 460 files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 15:31:34 +03:00

16 lines
543 B
Text

# visible.ludic — L3: a program in no module uses what module bank exports: a function to call
# and an event to listen to. Its private `add` and `balance` stay out of reach.
#
# Running it prints: 42 42
import "bank"
program Visible {
state VisibleState {
heard: int = 0
}
@On(Deposited) handler Heard(visible_st: mut VisibleState) { visible_st.heard += amount }
entry (bank_st: mut BankState, visible_st: VisibleState) {
deposit(bank_st, 30)
deposit(bank_st, 12)
print(`{total(bank_st)} {visible_st.heard}`)
}
}