docs: alias carry semantics + stdlib layout (step 4)

- specs §9: Namespace Alias Carry section (one level, own-wins, ambiguity,
  no chaining — 0114 noted for the still-ungated bare-call path), the
  three-tier import resolution (file dir -> cwd -> stdlib search path /
  SX_STDLIB_PATH), a Standard Library Layout section, real-layout examples
  replacing the stale modules/std/std.sx ones.
- readme: carry-rule teaser with the std namespace-tail example (verified
  to compile and run as written).
- CLAUDE.md: file-roles rows for std.sx/std//ffi//math//build.sx,
  tests/fixtures, and the PLAN-STDLIB tracker.
This commit is contained in:
agra
2026-06-11 08:46:17 +03:00
parent 698f75d79a
commit b8748aee16
3 changed files with 108 additions and 10 deletions

View File

@@ -441,6 +441,26 @@ struct / pack fn / protocol body is instantiated in the module that defines it,
e.g. `List(T).append`'s `alloc: Allocator` is visible there regardless of the call
site.)
**Namespace aliases carry one level.** A namespaced import is an ordinary
declaration, and flat-importing the module that declares it makes the alias
usable in the importer — there is no `pub` keyword. The stdlib prelude uses
exactly this: `#import "modules/std.sx"` gives every bare prelude name
(`print`, `List`, `Context`, …) plus the carried namespaces of std's tail:
```sx
#import "modules/std.sx";
main :: () {
gpa := mem.GPA.init(); // mem :: #import — carried from std.sx
log.warn("count = {}", 3);
s := xml.escape("<a & b>");
}
```
Carried aliases follow declaration rules: an own declaration shadows a carried
alias, two flat imports carrying the same alias make its use ambiguous, and
carry does not chain through a second flat hop.
### Implicit Context
Every program gets an implicit `context` with a default allocator: