feat(lang): open registry - other modules' defs, in an order imports cannot change
A def from another module into a registry that is not open is refused, and defs go through visibility (the registry exported, its module in the definer's uses). Index order: the declaring module's entries, then the other modules' by module name, each in reading order. A registry entry is emitted as its own file's code, so what it names is seen from its own module. Reseed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
05b09b4c98
commit
6cfaaf0bf9
19 changed files with 49801 additions and 47689 deletions
7
examples/rejected/closed_kit/index.ludic
Normal file
7
examples/rejected/closed_kit/index.ludic
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# closed_kit/index.ludic - a registry that is not open
|
||||
module kit
|
||||
export property Tool {
|
||||
name: string = ""
|
||||
}
|
||||
export registry Tools of Tool
|
||||
def Tools axe { name: "Axe" }
|
||||
10
examples/rejected/hidden_kit/index.ludic
Normal file
10
examples/rejected/hidden_kit/index.ludic
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# hidden_kit/index.ludic - open, but not exported: nothing outside kit can name it
|
||||
module kit
|
||||
export property Tool {
|
||||
name: string = ""
|
||||
}
|
||||
open registry Tools of Tool
|
||||
def Tools axe { name: "Axe" }
|
||||
export function tool_count() -> int {
|
||||
return TOOLS_COUNT
|
||||
}
|
||||
8
examples/rejected/registry_closed.ludic
Normal file
8
examples/rejected/registry_closed.ludic
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# L8 + L3: only an `open registry` takes defs from another module
|
||||
import "closed_kit"
|
||||
program RegistryClosed {
|
||||
def Tools saw { name: "Saw" }
|
||||
entry {
|
||||
print(TOOLS_COUNT)
|
||||
}
|
||||
}
|
||||
8
examples/rejected/registry_hidden.ludic
Normal file
8
examples/rejected/registry_hidden.ludic
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# L8 + L3: a def goes through visibility like any reference - the registry must be exported
|
||||
import "hidden_kit"
|
||||
program RegistryHidden {
|
||||
def Tools saw { name: "Saw" }
|
||||
entry {
|
||||
print(tool_count())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue