string type with automatic memory management — the compiler handles allocation and deallocation so you never call malloc or free for ordinary string work. On top of that foundation, the plstd string library provides the full set of string utility functions you’d expect from a systems language: comparison, copying, concatenation, searching, and more. Every function in the library has architecture-optimized implementations for x86_64 Linux and ARM64 macOS, selected automatically at compile time.
The string Type
Declare a string with the string keyword and assign it a string literal. Concatenation uses the + operator, and the built-in len() function gives you the character count — no boilerplate, no null-terminator arithmetic.
Strings in C△ are managed by the compiler. You do not need to allocate or free them manually. The compiler inserts the necessary lifetime management during compilation.
Comparison
Compare strings with== and != exactly as you would with any other value. The compiler lowers these operators to strcmp calls automatically — you get readable code without giving up correctness.
String Utility Functions
The plstdstring library exposes the following functions. Import them with using <plstd>; or individually with using strcmp from <plstd>;.
strcmp(a, b) — Compare two strings
strcmp(a, b) — Compare two strings
Returns
0 if a and b are equal, a negative value if a sorts before b, and a positive value if a sorts after b.strncmp(a, b, n) — Compare first n characters
strncmp(a, b, n) — Compare first n characters
Compares up to
n characters of a and b. Useful when you only care about a prefix.strcpy(dest, src) — Copy a string
strcpy(dest, src) — Copy a string
Copies
src into dest and returns dest. Make sure dest has enough space to hold src.strncpy(dest, src, n) — Copy up to n characters
strncpy(dest, src, n) — Copy up to n characters
Copies at most
n characters from src into dest. Pads with null bytes if src is shorter than n.strcat(dest, src) — Concatenate strings
strcat(dest, src) — Concatenate strings
Appends
src to the end of dest and returns dest. For most cases the + operator is more ergonomic; use strcat when working with pre-allocated buffers.strncat(dest, src, n) — Concatenate up to n characters
strncat(dest, src, n) — Concatenate up to n characters
Appends at most
n characters from src onto dest.strlen(s) — String length
strlen(s) — String length
Returns the number of characters in
s, not counting the null terminator. In most C△ code you should prefer the built-in len() — see the section below. Use strlen when you need the plstd-level function explicitly.strdup(s) — Duplicate a string
strdup(s) — Duplicate a string
Allocates a new string and copies
s into it, returning the copy.strchr(s, c) — Find a character
strchr(s, c) — Find a character
Returns the index of the first occurrence of character
c in s, or -1 if not found.strstr(haystack, needle) — Find a substring
strstr(haystack, needle) — Find a substring
Returns the index of the first occurrence of
needle in haystack, or -1 if not found.Architecture Optimization
The plstd string library ships two implementations:
string_x86.plib for x86_64 Linux and string_arm64.plib for ARM64 macOS. Both expose identical function signatures — string.plib uses conditional compilation (#ifdef __x86_64__ / #ifdef __aarch64__) to route each call to the appropriate backend. You never need to select an implementation yourself; the compiler handles it based on your build target.Using the len() Built-in
len() is a language built-in — not a plstd function — so it requires no import and works across multiple collection types. Use it in preference to strlen for everyday string length checks.
len() works with string, dynam arrays, and tuple collections. For anything else, reach for the appropriate plstd function.