ludic/examples/modules/private_twins.ludic
Orkuncakilkaya a09b622a1d feat(lang): a module's private names are its own
A private function, var or const no longer collides with the same
spelling in another module, in no module or in the runtime: where two
meet, each private one is renamed for its module (seed$shop), with every
reference its module writes that no local shadows. Exported names stay
one namespace. Nothing is renamed without a clash. Reseed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 07:08:05 +03:00

15 lines
452 B
Text

# private_twins.ludic — L3: a module's private names are its own. shop and weather each have a
# private `seed`, `dice` and `LIMIT`, and the program has a `seed` of its own; none of them collide,
# and each module's code reaches its own.
#
# Running it prints: 105 41 7
import "twins/shop"
import "twins/weather"
program PrivateTwins {
function seed() -> int {
return 7
}
entry {
print(`{shop_seed()} {weather_seed()} {seed()}`)
}
}