SLString.sleela
lib/core/SLString.sleela · 125 line(s) · sleela
< lib/core/SLString.sleela >
< SLeeLa Standard Library Definition. >
< Definition: SLString -- the core/base text value contract (see >
< lib/CORE.BASE.md). This is the small, bootstrap-level String contract the >
< language base needs; the richer utility surface lives in lib/text/SLString. >
< >
< SLeeLa's built-in `String` scalar exposes only concatenation (+) and >
< equality (==/!=) to source; there is no char type or char-level indexing. >
< The core contract therefore implements the operations expressible in the >
< language and names the char-level ones as crossing the explicit VM/OS bridge >
< (CORE.BASE.md: "Runtime-sensitive operations should cross an explicit VM/OS >
< bridge."). Comments use the angle-bracket style; #sleela 2.1. >
#sleela 2.5
material;
< SLeeLa core/base language contract. >
class SLString {
< ---- value + lifecycle --------------------------------------------- >
String value = "";
< 0 inert, 1 active (set at least once) >
int state;
< number of mutations applied >
int count;
void reset() { value = ""; state = 0; count = 0; }
void activate() { state = 1; count = count + 1; }
boolean active(){ return state == 1; }
int status() { return state; }
< ---- in-language text value ---------------------------------------- >
void set(String v) { value = v; state = 1; count = count + 1; }
String get() { return value; }
void clear() { value = ""; state = 0; }
boolean isEmpty() { return value == ""; }
boolean isNull() { return value == null; }
boolean equals(String other) { return value == other; }
< Concatenation is the one native text-producing operator. >
String concat(String other) { value = value + other; count = count + 1; return value; }
< repeat(n): value repeated n times (n <= 0 -> ""), built with + in a loop. >
String repeat(int n) {
String out = "";
int i = 0;
while (i < n) { out = out + value; i = i + 1; }
return out;
}
< notEmpty / isBlankLike: base emptiness helpers (real, == only). >
boolean notEmpty() { return value != null && value != ""; }
boolean isBlankLike() { return value == null || value == ""; }
< defaultIfEmpty(fallback): fall back to a default when unset/empty (real). >
String defaultIfEmpty(String fallback) {
if (value == null || value == "") { return fallback; }
return value;
}
< append(tail): fluent in-language append (real). >
SLString append(String tail) { value = value + tail; count = count + 1; return this; }
< ---- bridged char-level operations --------------------------------- >
< Char-level work needs the raw code units SLeeLa never exposes; these cross >
< the VM/OS bridge and return an inspectable descriptor, never a faked value. >
String bridge(String op) { return "core.string.bridge:" + op + ":" + value; }
String bridgeArg(String op, String a) { return "core.string.bridge:" + op + ":" + value + ":" + a; }
String length() { return bridge("length"); }
String charAt(String idx) { return bridgeArg("charAt", idx); }
String toUpperCase() { return bridge("toUpperCase"); }
String toLowerCase() { return bridge("toLowerCase"); }
String trim() { return bridge("trim"); }
String indexOf(String needle) { return bridgeArg("indexOf", needle); }
String compareTo(String other) { return bridgeArg("compareTo", other); }
< ---- introspection ------------------------------------------------- >
String typeName() { return "SLeeLa.core.SLString"; }
boolean available() { return true; }
< SLCloneable / SLDisposable intent (core base contracts, see CORE.BASE.md). >
SLString copy() { SLString c = new SLString(); c.set(value); return c; }
void dispose() { value = ""; state = 0; count = 0; }
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
< Eleven catalogued attributes with getter/setter pairs, so a GUI, loader, >
< or catalog can read and (where appropriate) override each record. >
< Values are faithful to the subject's real origin where publicly known. >
String metaVersion = "1.0.0";
int metaId = 11518;
String metaAuthor = "SLeeLa standard library";
String metaDate = "2026-10-23";
String metaCopyright = "MEARVK LLC";
String metaTrademark = "none";
String metaCorporation = "MEARVK LLC";
String metaOrigin = "International";
String metaBirthDate = "2026";
int metaScienceRating = 9;
String metaNationalSchedule = "SLeeLa CORE.BASE (SLString); Unicode / ISO/IEC 10646";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
}