refactor(lang): rename the str type (and stringify builtin) to string
Expand the abbreviated string type and its conversion builtin to the full
word everywhere:
str -> string (the immutable-string type)
str(x) -> str -> string(x) -> string (the stringify builtin;
what `{…}` interpolation calls)
Types are recognized by identifier, and llty maps both spellings to LLVM
`ptr`, so this is an atomic source rewrite: type annotations, the Ludic
type tags, the builtin name/dispatch, and the interpolation desugar, plus
the grammars, LSP, docs (type-str -> type-string, fn-str -> fn-string), and
inventory. int/bool stay (universally accepted, like Math).
Reseeded; C-free fixpoint holds; all suites green (45/24/29); site + check.py OK.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
4c48077d68
commit
b7745a4600
70 changed files with 207 additions and 207 deletions
|
|
@ -4,4 +4,4 @@ title: Text
|
|||
order: 6
|
||||
---
|
||||
|
||||
String queries and building over <code>str</code> values — length, character access, substrings, search, prefix/suffix tests, and int conversion. Arguments are positional. Strings are byte sequences, so indices and lengths count bytes.
|
||||
String queries and building over <code>string</code> values — length, character access, substrings, search, prefix/suffix tests, and int conversion. Arguments are positional. Strings are byte sequences, so indices and lengths count bytes.
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program FirstIsDigit {
|
||||
var entry: str = "7up"
|
||||
var entry: string = "7up"
|
||||
|
||||
handler Check phase Update {
|
||||
let c = Text.char_at(entry, 0)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ name: Text.concat
|
|||
category: text
|
||||
kind: namespace-method
|
||||
tokens: Text.concat
|
||||
sig: Text.concat(a, b) -> str
|
||||
sig: Text.concat(a, b) -> string
|
||||
tip: Join two strings into a new one.
|
||||
order: 8
|
||||
ns: Text
|
||||
|
|
@ -19,7 +19,7 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program Greeting {
|
||||
var name: str = "world"
|
||||
var name: string = "world"
|
||||
|
||||
handler Build phase Update {
|
||||
let line = Text.concat("hello ", name) # "hello world"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program Filter {
|
||||
var line: str = "error: disk full"
|
||||
var line: string = "error: disk full"
|
||||
|
||||
handler Scan phase Update {
|
||||
if Text.contains(line, "error") {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program IsImage {
|
||||
var filename: str = "hero.png"
|
||||
var filename: string = "hero.png"
|
||||
|
||||
handler Classify phase Update {
|
||||
let png = Text.ends_with(filename, ".png") # true
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program Guess {
|
||||
var answer: str = "swordfish"
|
||||
var attempt: str = "swordfish"
|
||||
var answer: string = "swordfish"
|
||||
var attempt: string = "swordfish"
|
||||
|
||||
handler Check phase Update {
|
||||
if Text.equals(attempt, answer) {
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ name: Text.from_int
|
|||
category: text
|
||||
kind: namespace-method
|
||||
tokens: Text.from_int
|
||||
sig: Text.from_int(n) -> str
|
||||
sig: Text.from_int(n) -> string
|
||||
tip: Render an integer as a string.
|
||||
order: 10
|
||||
ns: Text
|
||||
member: from_int
|
||||
---
|
||||
|
||||
Returns the decimal text of the integer <code>n</code> — <code>Text.from_int(1234)</code> is <code>"1234"</code>, and negatives keep their sign. It is the same conversion as the bare <code>str(n)</code> and the inverse of <code>Text.to_int</code>. Use it when you need a number as characters — to measure its width, concatenate it, or store it — though drawing a number to the screen is better done with <code>Screen.draw_number</code>.
|
||||
Returns the decimal text of the integer <code>n</code> — <code>Text.from_int(1234)</code> is <code>"1234"</code>, and negatives keep their sign. It is the same conversion as the bare <code>string(n)</code> and the inverse of <code>Text.to_int</code>. Use it when you need a number as characters — to measure its width, concatenate it, or store it — though drawing a number to the screen is better done with <code>Screen.draw_number</code>.
|
||||
|
||||
Parameters:
|
||||
- `n` — the integer to render
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program KeyValue {
|
||||
var pair: str = "hp=42"
|
||||
var pair: string = "hp=42"
|
||||
|
||||
handler Parse phase Update {
|
||||
let eq = Text.index_of(pair, "=") # 2
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ name: Text.join
|
|||
category: text
|
||||
kind: namespace-method
|
||||
tokens: Text.join
|
||||
sig: Text.join(parts, sep) -> str
|
||||
sig: Text.join(parts, sep) -> string
|
||||
tip: Join a list of strings with a separator.
|
||||
order: 18
|
||||
ns: Text
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program NameWidth {
|
||||
var label: str = "player one"
|
||||
var label: string = "player one"
|
||||
|
||||
handler Draw phase Render {
|
||||
let width = Text.length(label) * 6 # 6 px per glyph
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ name: Text.lower
|
|||
category: text
|
||||
kind: namespace-method
|
||||
tokens: Text.lower
|
||||
sig: Text.lower(s) -> str
|
||||
sig: Text.lower(s) -> string
|
||||
tip: A lowercased copy of a string.
|
||||
order: 12
|
||||
ns: Text
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ name: Text.pad_left
|
|||
category: text
|
||||
kind: namespace-method
|
||||
tokens: Text.pad_left
|
||||
sig: Text.pad_left(s, width) -> str
|
||||
sig: Text.pad_left(s, width) -> string
|
||||
tip: Pad with spaces on the left to a width.
|
||||
order: 15
|
||||
ns: Text
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ name: Text.pad_right
|
|||
category: text
|
||||
kind: namespace-method
|
||||
tokens: Text.pad_right
|
||||
sig: Text.pad_right(s, width) -> str
|
||||
sig: Text.pad_right(s, width) -> string
|
||||
tip: Pad with spaces on the right to a width.
|
||||
order: 16
|
||||
ns: Text
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ name: Text.repeat
|
|||
category: text
|
||||
kind: namespace-method
|
||||
tokens: Text.repeat
|
||||
sig: Text.repeat(s, n) -> str
|
||||
sig: Text.repeat(s, n) -> string
|
||||
tip: A string repeated n times.
|
||||
order: 14
|
||||
ns: Text
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ name: Text.replace
|
|||
category: text
|
||||
kind: namespace-method
|
||||
tokens: Text.replace
|
||||
sig: Text.replace(s, from, to) -> str
|
||||
sig: Text.replace(s, from, to) -> string
|
||||
tip: Replace every occurrence of a substring.
|
||||
order: 19
|
||||
ns: Text
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ name: Text.slice
|
|||
category: text
|
||||
kind: namespace-method
|
||||
tokens: Text.slice
|
||||
sig: Text.slice(s, a, b) -> str
|
||||
sig: Text.slice(s, a, b) -> string
|
||||
tip: A substring covering bytes [a, b).
|
||||
order: 2
|
||||
ns: Text
|
||||
|
|
@ -20,7 +20,7 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program FirstWord {
|
||||
var line: str = "hello world"
|
||||
var line: string = "hello world"
|
||||
|
||||
handler Split phase Update {
|
||||
let space = Text.index_of(line, " ") # 5
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ name: Text.split
|
|||
category: text
|
||||
kind: namespace-method
|
||||
tokens: Text.split
|
||||
sig: Text.split(s, sep) -> []str
|
||||
sig: Text.split(s, sep) -> []string
|
||||
tip: Split a string on a separator into a list.
|
||||
order: 17
|
||||
ns: Text
|
||||
member: split
|
||||
---
|
||||
|
||||
Splits <code>s</code> at every occurrence of the non-empty separator <code>sep</code> and returns the pieces as a <code>[]str</code> — the inverse of <code>Text.join</code>. Adjacent separators yield empty pieces, and a string with no separator returns a one-element list holding the whole string. Use it to parse CSV rows, command arguments, or delimited save data.
|
||||
Splits <code>s</code> at every occurrence of the non-empty separator <code>sep</code> and returns the pieces as a <code>[]string</code> — the inverse of <code>Text.join</code>. Adjacent separators yield empty pieces, and a string with no separator returns a one-element list holding the whole string. Use it to parse CSV rows, command arguments, or delimited save data.
|
||||
|
||||
```ludic
|
||||
program Demo {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program Command {
|
||||
var input: str = "/say hello"
|
||||
var input: string = "/say hello"
|
||||
|
||||
handler Parse phase Update {
|
||||
if Text.starts_with(input, "/say ") {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program ParseAmount {
|
||||
var typed: str = "250"
|
||||
var typed: string = "250"
|
||||
|
||||
handler Apply phase Update {
|
||||
let gold = Text.to_int(typed) # 250
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ name: Text.trim
|
|||
category: text
|
||||
kind: namespace-method
|
||||
tokens: Text.trim
|
||||
sig: Text.trim(s) -> str
|
||||
sig: Text.trim(s) -> string
|
||||
tip: A copy with surrounding whitespace removed.
|
||||
order: 13
|
||||
ns: Text
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ name: Text.upper
|
|||
category: text
|
||||
kind: namespace-method
|
||||
tokens: Text.upper
|
||||
sig: Text.upper(s) -> str
|
||||
sig: Text.upper(s) -> string
|
||||
tip: An uppercased copy of a string.
|
||||
order: 11
|
||||
ns: Text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue