From 2ee8718476f647b60bc71814c3d7981fe0ebbd90 Mon Sep 17 00:00:00 2001 From: tomoaki Date: Sun, 28 Dec 2025 13:57:31 +0900 Subject: [PATCH] docs: note NYASH_STR_CP toggle for strings --- docs/reference/language/strings.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/reference/language/strings.md b/docs/reference/language/strings.md index 8703ea2c..8db59bc7 100644 --- a/docs/reference/language/strings.md +++ b/docs/reference/language/strings.md @@ -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 byte‑level 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 UTF‑8 string value. Public text APIs are CP‑indexed. - `Utf8CursorBox`: delegated implementation for scanning and slicing `StringBox` as CPs.