file-local / package-local decls

This commit is contained in:
2026-08-09 17:01:05 +02:00
parent a7a32894f3
commit 8785912b73
15 changed files with 369 additions and 152 deletions
+6 -6
View File
@@ -208,14 +208,14 @@ mem :: import "@std/mem"
value :: math.sum(other_math.value, 1)
```
Top-level declarations are public by default. Prefix a declaration with `hide`
to keep it local to its package; sibling files can use it, but importing packages
cannot. Leading underscores have no visibility meaning. Imports are always file-local
and cannot be hidden or re-exported:
Top-level declarations are public by default. Prefix a declaration with bare `hide`
to make it package-local, or spell the scope explicitly with `hide(package)` or
`hide(file)`. Leading underscores have no visibility meaning. Imports are always
file-local and cannot use visibility modifiers or be re-exported:
```bro
hide helper func() i32 { return 42 }
hide State :: struct { value i32 }
hide shared_helper func() i32 { return 42 }
hide(file) implementation_detail func() i32 { return shared_helper() }
```
Current prototype features: