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>
15 lines
276 B
Text
15 lines
276 B
Text
# L3: a port is bound once
|
|
program PortTwice {
|
|
port Clock { now: fn() -> int }
|
|
function hours() -> int {
|
|
return 3
|
|
}
|
|
function minutes() -> int {
|
|
return 4
|
|
}
|
|
bind Clock { now: fn hours }
|
|
bind Clock { now: fn minutes }
|
|
entry {
|
|
print(Clock.now())
|
|
}
|
|
}
|