A port is a record of function values a module calls through (Clock.now()) without naming the module that answers. A port used and never bound, a bind missing a required member or naming one the port lacks, and a second bind are refused; the binder must see the port, and what it binds is checked from its own file. Reseed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 lines
377 B
Text
13 lines
377 B
Text
# clock/index.ludic - the clock needs the time of day and asks for it through a port: it names
|
|
# no module that answers, so it `uses` only units
|
|
module clock uses units
|
|
export port Clock {
|
|
now: fn() -> int
|
|
day: fn() -> int = fn first_day
|
|
}
|
|
function first_day() -> int {
|
|
return 1
|
|
}
|
|
export function hour_of_day() -> int {
|
|
return Clock.now() - (Clock.day() - 1) * HOURS
|
|
}
|