docs: note NYASH_STR_CP toggle for strings

This commit is contained in:
2025-12-28 13:57:31 +09:00
parent bb92a538b4
commit 2ee8718476

View File

@ -8,6 +8,15 @@ Status: Design committed. This document defines how Nyash treats text vs bytes a
- Bytes are not text. Byte operations live in a separate `ByteCursorBox` and bytelevel instructions.
- Conversions are explicit.
## Implementation Note (Current Runtime)
The Rust runtime currently supports a legacy performance/compatibility switch:
- Default: **byte** indexing for `length/indexOf/lastIndexOf/substring`
- `NYASH_STR_CP=1`: **code point** indexing for the same APIs
This applies to both primitive `String` and `StringBox` paths. Long-term, the language-level SSOT is CP semantics; the env toggle exists to keep migrations reversible while the VM/runner paths are being unified.
## Model
- `StringBox`: immutable UTF8 string value. Public text APIs are CPindexed.
- `Utf8CursorBox`: delegated implementation for scanning and slicing `StringBox` as CPs.