feat(lang): layers - module flow in layer app uses base, items
The modules of one layer use each other freely and may go round; anything outside the layer is held to the module's uses, and a layered module with no uses reaches nothing outside it. The cycle check walks the graph with each layer as one node, so a cycle leaving a layer is refused. ludic deps shows the layers and counts the largest cycle without their own edges. Reseed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e3219f17dd
commit
7b8c134c21
20 changed files with 47359 additions and 46193 deletions
5
examples/modules/layered/hud/index.ludic
Normal file
5
examples/modules/layered/hud/index.ludic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# hud/index.ludic - in layer app: it reaches menu back - a cycle, allowed inside the layer
|
||||
module hud in layer app
|
||||
export function hud_lines() -> int {
|
||||
return menu_title() + 1
|
||||
}
|
||||
5
examples/modules/layered/items/index.ludic
Normal file
5
examples/modules/layered/items/index.ludic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# items/index.ludic - below the layer: it uses nothing
|
||||
module items uses
|
||||
export function item_count() -> int {
|
||||
return 3
|
||||
}
|
||||
8
examples/modules/layered/menu/index.ludic
Normal file
8
examples/modules/layered/menu/index.ludic
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# menu/index.ludic - in layer app: it reaches hud (same layer) freely, and items through its uses
|
||||
module menu in layer app uses items
|
||||
export function menu_rows() -> int {
|
||||
return item_count() + hud_lines()
|
||||
}
|
||||
export function menu_title() -> int {
|
||||
return 1
|
||||
}
|
||||
13
examples/modules/layers.ludic
Normal file
13
examples/modules/layers.ludic
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# layers.ludic — L3: `module menu in layer app uses items`. The modules of one layer use each other
|
||||
# freely and may go round (menu and hud use each other); anything outside the layer is held to the
|
||||
# module's `uses` - a layered module with no uses line may reach nothing outside its layer.
|
||||
#
|
||||
# Running it prints: 5
|
||||
import "layered/items"
|
||||
import "layered/menu"
|
||||
import "layered/hud"
|
||||
program Layers {
|
||||
entry {
|
||||
print(menu_rows())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue