feat(lang): a module's private records and events are its own

A property or event a module does not export no longer collides with
another module's of the same spelling: each private one is renamed for
its module, with the types, new, emit and @On written in that module.
Exported ones stay one namespace; two events of one spelling are now
refused. Generic records, entity components and component or view
records stay global. Reseed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 11:02:48 +03:00
parent 029a1ebba2
commit 69352babfd
17 changed files with 50199 additions and 44822 deletions

View file

@ -0,0 +1,20 @@
# fishing/index.ludic - a private record and a private event, spelt as hunting spells its own
module fishing
property Catch {
fish: int = 0
}
event Landed { fish: int }
var landed: int = 0
var last: Catch = null
@On(Landed) handler Count { landed += fish }
function catch_new(n: int) -> Catch {
let c = new Catch
c.fish = n
return c
}
export function fishing_day() -> int {
last = catch_new(3)
emit Landed(fish: last.fish)
emit Landed(fish: 4)
return landed
}

View file

@ -0,0 +1,15 @@
# hunting/index.ludic - a Catch and a Landed of its own, with other fields
module hunting
property Catch {
name: string = ""
weight: float = 0.0
}
event Landed { name: string }
var heard: string = ""
@On(Landed) handler Hear { heard = heard + name }
export function hunting_day() -> string {
let c = new Catch
c.name = "hare"
emit Landed(name: c.name)
return heard
}

View file

@ -0,0 +1,12 @@
# private_kinds.ludic — L3: a module's private records and events are its own too. fishing and
# hunting each have a record Catch and an event Landed, with different fields; each module's `new`,
# types, `emit` and `@On` reach its own.
#
# Running it prints: 7 hare
import "kinds/fishing"
import "kinds/hunting"
program PrivateKinds {
entry {
print(`{fishing_day()} {hunting_day()}`)
}
}