tur/str-build
minimal cstr-building primitives (str-concat, int->str).
A dependency-free leaf module: two heap-allocating :cstr builders and nothing else -- no typeclass instances, no transitive loads. This lets both stdlib/str.tur and stdlib/range-bound.tur pull the builders without dragging extra Eq/Show instances into a consumer's load graph (which would perturb instance resolution for unrelated types).
Both defns have inline-C bodies for the compiled path and layout-exact interpreter natives (registered as "str-concat" / "int->str" in src/turi/interpreter_natives.c) that override them under --interpret, so the same binding name runs on both the compiled and tree-walking paths.
Since: interp-string-natives-and-range-show-plan (Phase 1)
str-concat
(str-concat [a :cstr b :cstr] :cstr)
concatenate two NUL-terminated strings into a new heap buffer.
| a | first :cstr (NUL-terminated) | |
| b | second :cstr (NUL-terminated) |
A newly heap-allocated :cstr containing the bytes of a followed by b, NUL-terminated. The caller is responsible for freeing the returned pointer.
(str-concat "Hello, " "world") ; => "Hello, world"
Since: Phase B1
int->str
(int->str [v :int] :cstr)
format an int64 as a decimal :cstr.
| v | the integer to render |
A freshly heap-allocated NUL-terminated :cstr containing the decimal digits of v (with a leading '-' for negatives). Caller owns the buffer.
(int->str 42) ; => "42" (int->str -7) ; => "-7"
Since: interp-string-natives-and-range-show-plan (Phase 1)