feat(lang): friend module lab of fishing, data - a friend of the modules it names
A scoped friend sees those modules' private names and only the exports of every other; a plain friend module still sees everything. Reseed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f4533331e7
commit
70d05bd504
8 changed files with 41388 additions and 41329 deletions
12
examples/modules/friend_of.ludic
Normal file
12
examples/modules/friend_of.ludic
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# friend_of.ludic — L3: `friend module lab of bank` sees bank's private names and no other module's;
|
||||
# a test harness reaches inside exactly what it tests. `friend module lab` alone still sees all.
|
||||
#
|
||||
# Running it prints: 7 7
|
||||
import "bank"
|
||||
program FriendOf {
|
||||
friend module lab of bank
|
||||
entry {
|
||||
add(7)
|
||||
print(`{balance} {total()}`)
|
||||
}
|
||||
}
|
||||
10
examples/rejected/friend_scope.ludic
Normal file
10
examples/rejected/friend_scope.ludic
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# L3: a friend of kit is not a friend of bank - bank's private `add` stays out of reach
|
||||
import "private_bank"
|
||||
import "private_kit"
|
||||
program FriendScope {
|
||||
friend module lab of kit
|
||||
entry {
|
||||
add(5)
|
||||
print(total())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue