refactor(stdlib): consolidate System.* onto Os.*, retire duplicated members
All checks were successful
docs / build-and-deploy (push) Successful in 2s

`System.*` and the newer `Os.*` (added in #21) both covered the environment
around the game, with four members (`arg`, `arg_count`, `env`, `exit`) lowering
byte-for-byte identically and the standard streams overlapping in concern. That
is a user-facing ambiguity (`System.env` vs `Os.env` are indistinguishable) and
a drift hazard (two copy-pasted codegen paths).

Make `Os.*` the single canonical environment/process namespace and retire the
overlapping `System.*` members:

- Remove `System.{arg, arg_count, env, exit, stdout, stderr}` from the namespace
  dispatch (selfhost/emit_expr.ludic). Use `Os.arg`/`Os.arg_count`/`Os.env`/
  `Os.exit` and `Os.stdout_write`/`Os.stderr_write` instead.
- `System.*` now covers only its unique low-level surface: the raw file handles
  (`file_open/read/write/seek/tell/close`), `read_char`, and `run`.
- The bare `arg`/`exit`/`getenv`/`file_stdout`/`file_stderr` intrinsics stay —
  they are the primitive layer the self-hosted compiler itself uses; only the
  redundant *namespaced* sugar is gone.
- Docs: drop the six retired `docs/language/system/*` pages, retune the section
  blurb, update inventory.json and the LSP signature table.
- Secondary finding from the issue: cross-link `Text.upper`/`Text.lower`
  (ASCII-only) to `Unicode.upper`/`Unicode.lower` (full Unicode case mapping).

Reseeded; C-free bootstrap fixpoint holds. All suites green (56 test / 29
selfhost / 29 test-tools); docs cover every implemented feature (291 ns-methods).

Closes #40

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-08-30 22:54:28 +03:00
parent dd4f5a26ad
commit ac1e8d157d
14 changed files with 3762 additions and 3920 deletions

View file

@ -356,11 +356,11 @@ function emit_ns_call(ns: pointer, meth: pointer, e: Node) -> Val {
if (meth == "local_id") { bare = "local_id" }
}
if (ns == "System") {
if (meth == "arg") { bare = "arg" }
if (meth == "arg_count") { bare = "arg_count" }
if (meth == "exit") { bare = "exit" }
# System.* is the low-level file/process surface only. The environment slice
# (arg/arg_count/env/exit) and the standard streams (stdout/stderr) were
# duplicated by the canonical Os.* namespace and have been retired — see
# Os.arg/arg_count/env/exit and Os.stdout_write/stderr_write (issue #40).
if (meth == "run") { bare = "run" }
if (meth == "env") { bare = "getenv" }
if (meth == "read_char") { bare = "read_char" }
if (meth == "file_open") { bare = "file_open" }
if (meth == "file_read") { bare = "file_read" }
@ -368,8 +368,6 @@ function emit_ns_call(ns: pointer, meth: pointer, e: Node) -> Val {
if (meth == "file_seek") { bare = "file_seek" }
if (meth == "file_tell") { bare = "file_tell" }
if (meth == "file_close") { bare = "file_close" }
if (meth == "stdout") { bare = "file_stdout" }
if (meth == "stderr") { bare = "file_stderr" }
}
if (ns == "Save") {
if (meth == "write") { bare = "save" }