Lambda Smalltalk API Reference
Auto-generated from source code comments.
Important Notes
Primitive Methods Can Be Overridden
Methods implemented as Rust primitives can be overridden by defining a Smalltalk method with the same name. User-defined methods take precedence over primitives.
"Override a primitive method"
String >> size
^ 999
!
'hello' size. "=> 999 (user-defined method is called)"
Note: Overriding primitives will impact performance, as the optimized Rust implementation will be bypassed in favor of your Smalltalk code.
Table of Contents
Built-in Classes
- Array
- Base64 class
- ByteArray
- ByteArray class
- Character
- ChildProcess
- ChildProcess class
- Csv class
- CsvReader
- DateTime class
- Dict
- Dict class
- Directory class
- Env class
- File class
- Float
- Float class
- Hmac class
- Http class
- Integer
- Interval
- Interval class
- Json class
- OrderedCollection
- OrderedCollection class
- Path class
- Point
- Process class
- Random class
- Set
- Set class
- Sha2 class
- Sqlite
- Sqlite class
- Stdin class
- String
- StringStream
- StringStream class
- System class
- Tcp class
- TcpListener
- TcpListener class
- TcpStream
- Time class
- Toml class
- Yaml class
Standard Library
- Ansi class
- Array
- Array class
- CLI.ArgParser
- CLI.ParseResult
- Collection
- Collection class
- Core.Association class
- Core.Block
- Core.Exception class
- Core.Object
- Core.Object class
- Core.Path class
- Core.String
- Core.String class
- Core.Time class
- Dictionary
- Integer
- Maybe class
- Number
- Shell.Sh class
- String
Built-in Classes
Array
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
size | Primitive | - | Integer - number of elements | #(1 2 3) size "=> 3" |
at: | Primitive | index Integer - 1-based index | Any - element at index, or nil if out of bounds | #(10 20 30) at: 2 "=> 20" |
at:put: | Primitive | index Integer - 1-based index, value Any - value to store | Any - the stored value | arr at: 1 put: 'hello' |
first | Primitive | - | Any - first element, or nil if empty | #(10 20 30) first "=> 10" |
last | Primitive | - | Any - last element, or nil if empty | #(10 20 30) last "=> 30" |
add: | Primitive | value Any - value to append | self | arr add: 42 |
includes: | Primitive | value Any - value to search for | Boolean - true if found | #(1 2 3) includes: 2 "=> true" |
sort | Primitive | - | Array - new sorted array | #(3 1 2) sort "=> #(1 2 3)" |
indexOf: | Primitive | value Any - value to search for | Integer - 1-based index, or 0 if not found | #(10 20 30) indexOf: 20 "=> 2" |
join: | Primitive | separator String - separator between elements | String - joined string | #('a' 'b' 'c') join: '-' "=> 'a-b-c'" |
, | Primitive | other Array - array to append | Array - new concatenated array | #(1 2) , #(3 4) "=> #(1 2 3 4)" |
copyFrom:to: | Primitive | start Integer - 1-based start index, end Integer - 1-based end index (inclusive) | Array - new sliced array | #(10 20 30 40) copyFrom: 2 to: 3 "=> #(20 30)" |
asString | Primitive | - | String - string representation | #(1 2 3) asString "=> '#(1 2 3)'" |
sum | Primitive | - | Number - sum of all numeric elements | #(1 2 3 4 5) sum "=> 15" |
max | Primitive | - | Object - maximum element or nil if empty | #(3 1 4 1 5) max "=> 5" |
min | Primitive | - | Object - minimum element or nil if empty | #(3 1 4 1 5) min "=> 1" |
average | Primitive | - | Number - average of all numeric elements (0 if empty) | #(1 2 3 4 5) average "=> 3" |
Base64 class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
encode: | Primitive | data String|ByteArray - data to encode | String - base64 encoded string | Base64 encode: 'Hello, World!' |
decode: | Primitive | string String - base64 string to decode | String - decoded data | Base64 decode: 'SGVsbG8sIFdvcmxkIQ==' |
ByteArray
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
at: | Primitive | index Integer - 1-based index | Integer - byte value (0-255) | bytes at: 1 |
at:put: | Primitive | index Integer - 1-based index, value Integer - byte value (0-255) | Integer - stored value | bytes at: 1 put: 255 |
size | Primitive | - | Integer - number of bytes | bytes size |
asString | Primitive | - | String - UTF-8 string from bytes | bytes asString |
copyFrom:to: | Primitive | start Integer - 1-based start index, end Integer - 1-based end index (inclusive) | ByteArray - new sliced byte array | bytes copyFrom: 1 to: 10 |
ByteArray class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
new: | Primitive | size Integer - number of bytes | ByteArray - new byte array filled with zeros | ByteArray new: 10 |
fromString: | Primitive | string String - string to convert | ByteArray - UTF-8 bytes of string | ByteArray fromString: 'hello' |
Character
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
isLetter | Primitive | - | Boolean - true if alphabetic | $a isLetter "=> true" |
isDigit | Primitive | - | Boolean - true if numeric digit | $5 isDigit "=> true" |
isAlphanumeric | Primitive | - | Boolean - true if letter or digit | $a isAlphanumeric "=> true" |
isUppercase | Primitive | - | Boolean - true if uppercase letter | $A isUppercase "=> true" |
isLowercase | Primitive | - | Boolean - true if lowercase letter | $a isLowercase "=> true" |
isWhitespace | Primitive | - | Boolean - true if whitespace character | $ isWhitespace "=> true" |
asUppercase | Primitive | - | Character - uppercase version | $a asUppercase "=> $A" |
asLowercase | Primitive | - | Character - lowercase version | $A asLowercase "=> $a" |
asInteger | Primitive | - | Integer - Unicode code point | $A asInteger "=> 65" |
asString | Primitive | - | String - single-character string | $A asString "=> 'A'" |
= | Primitive | other Character - character to compare | Boolean - true if equal | $a = $a "=> true" |
< | Primitive | other Character - character to compare | Boolean - true if less than | $a < $b "=> true" |
<= | Primitive | other Character - character to compare | Boolean - true if less than or equal | $a <= $a "=> true" |
> | Primitive | other Character - character to compare | Boolean - true if greater than | $b > $a "=> true" |
>= | Primitive | other Character - character to compare | Boolean - true if greater than or equal | $a >= $a "=> true" |
ChildProcess
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
isFinished | Primitive | - | Boolean - true if process has exited | child isFinished |
exitCode | Primitive | - | Integer|nil - exit code if finished, nil otherwise | child exitCode |
wait | Primitive | - | Integer - wait for process to finish and return exit code | child wait |
print | Primitive | - | self | child print |
printNl | Primitive | - | self | child printNl |
ChildProcess class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
spawn:args: | Primitive | command String - command to spawn, args Array - array of arguments | ChildProcess - spawned process handle | ChildProcess spawn: 'sleep' args: #('5') |
Csv class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
parse: | Primitive | string String - CSV string to parse | Array - array of rows (each row is an array of values) | Csv parse: 'name,age\nAlice,30' |
parse:options: | Primitive | string String - CSV string to parse, options Dict - options ('headers' -> true for Dict rows) | Array - parsed rows | Csv parse: 'name,age\nAlice,30' options: (Dict new at: 'headers' put: true) |
reader: | Primitive | string String - CSV string for streaming read | CsvReader - streaming CSV reader | Csv reader: (File read: 'data.csv') |
CsvReader
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
next | Primitive | - | Array|nil - next row, or nil at end | reader next |
atEnd | Primitive | - | Boolean - true if no more rows | reader atEnd |
DateTime class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
now | Primitive | - | Integer - current Unix timestamp in seconds | DateTime now |
parse: | Primitive | string String - ISO 8601 date string | Integer - Unix timestamp | DateTime parse: '2024-01-15T10:30:00Z' |
Dict
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
at: | Primitive | key String|Symbol - key to look up | Any - value for key, or nil if not found | dict at: 'name' "=> 'Alice'" |
at:put: | Primitive | key String|Symbol - key to store, value Any - value to store | Any - the stored value | dict at: 'name' put: 'Bob' |
keys | Primitive | - | Array - array of all keys | dict keys "=> #('name' 'age')" |
size | Primitive | - | Integer - number of key-value pairs | dict size "=> 2" |
includesKey: | Primitive | key String|Symbol - key to check | Boolean - true if key exists | dict includesKey: 'name' "=> true" |
removeKey: | Primitive | key String|Symbol - key to remove | Any - removed value, or nil if key not found | dict removeKey: 'name' |
values | Primitive | - | Array - array of all values | dict values "=> #('Alice' 30)" |
keysAndValues | Primitive | - | Array - array of Association (key->value pairs) | dict keysAndValues do: [:assoc | assoc key print. assoc value printNl] |
asString | Primitive | - | String - string representation | dict asString "=> 'Dict(name->Alice age->30)'" |
Dict class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
new | Primitive | - | Dict - new empty dictionary | Dict new |
Directory class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
entries: | Primitive | path String - directory path | Array - array of entry names in the directory | Directory entries: '.' |
Env class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
keys | Primitive | - | Array - array of all environment variable names | Env keys |
at: | Primitive | name String - environment variable name | String|nil - value or nil if not set | Env at: 'PATH' |
at:put: | Primitive | name String - environment variable name, value String - value to set | String - the value | Env at: 'MY_VAR' put: 'value' |
File class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
read: | Primitive | path String - file path to read | String - file contents | File read: 'data.txt' |
read:encoding: | Primitive | path String - file path to read, encoding String - encoding name ('utf-8', 'shift-jis', 'euc-jp', etc.) | String - file contents decoded with specified encoding | File read: 'data.txt' encoding: 'shift-jis' |
write:content: | Primitive | path String - file path to write, content String - content to write | true on success | File write: 'output.txt' content: 'Hello, World!' |
exists: | Primitive | path String - file path to check | Boolean - true if file exists | File exists: 'data.txt' |
delete: | Primitive | path String - file path to delete | true on success | File delete: 'temp.txt' |
glob: | Primitive | pattern String - glob pattern (e.g., '.txt', 'src/**/.rs') | Array - array of matching file paths | File glob: 'examples/*.st' |
appendTo:content: | Primitive | path String - file path to append to, content String - content to append | true on success | File appendTo: 'log.txt' content: 'New log entry' |
mkdir: | Primitive | path String - directory path to create | true on success | File mkdir: 'new_folder' |
copy:to: | Primitive | source String - source file path, dest String - destination file path | true on success | File copy: 'original.txt' to: 'backup.txt' |
move:to: | Primitive | source String - source file path, dest String - destination file path | true on success | File move: 'old.txt' to: 'new.txt' |
isDirectory: | Primitive | path String - path to check | Boolean - true if path is a directory | File isDirectory: 'src' |
Float
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
sin | Primitive | - | Float - sine value | 3.14159 sin "=> ~0.0" |
cos | Primitive | - | Float - cosine value | 0.0 cos "=> 1.0" |
tan | Primitive | - | Float - tangent value | 0.0 tan "=> 0.0" |
log | Primitive | - | Float - natural logarithm | 2.718 log "=> ~1.0" |
exp | Primitive | - | Float - e raised to this power | 1.0 exp "=> 2.718..." |
sqrt | Primitive | - | Float - square root | 16.0 sqrt "=> 4.0" |
log10 | Primitive | - | Float - base-10 logarithm | 100.0 log10 "=> 2.0" |
raisedTo: | Primitive | exponent Number - power to raise to | Float - result | 2.0 raisedTo: 10 "=> 1024.0" |
floor | Primitive | - | Integer - largest integer <= self | 3.7 floor "=> 3" |
ceiling | Primitive | - | Integer - smallest integer >= self | 3.2 ceiling "=> 4" |
rounded | Primitive | - | Integer - nearest integer | 3.5 rounded "=> 4" |
asString | Primitive | - | String - string representation | 3.14 asString "=> '3.14'" |
@ | Primitive | y Number - y coordinate | Point - new Point with self as x | 10.5 @ 20.5 "=> Point(10.5, 20.5)" |
Float class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
pi | Primitive | - | Float - mathematical constant pi | Float pi "=> 3.14159..." |
e | Primitive | - | Float - mathematical constant e | Float e "=> 2.71828..." |
infinity | Primitive | - | Float - positive infinity | Float infinity "=> Infinity" |
negativeInfinity | Primitive | - | Float - negative infinity | Float negativeInfinity "=> -Infinity" |
nan | Primitive | - | Float - Not a Number | Float nan "=> NaN" |
Hmac class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
sha256:key: | Primitive | data String - data to authenticate, key String - secret key | String - HMAC-SHA256 as hex string | Hmac sha256: 'message' key: 'secret' |
Http class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
get: | Primitive | url String - URL to fetch | String - response body, or nil on error | Http get: 'https://api.example.com/data' |
get:options: | Primitive | url String - URL to fetch, options Dict - options with 'headers' key for custom headers | String - response body, or nil on error | Http get: 'https://api.example.com' options: (Dict new at: 'headers' put: headers) |
post:body: | Primitive | url String - URL to post to, body String - request body (typically JSON) | String - response body, or nil on error | Http post: 'https://api.example.com' body: '{"name": "Alice"}' |
post:body:options: | Primitive | url String - URL to post to, body String - request body, options Dict - options with 'headers' key | String - response body, or nil on error | Http post: url body: json options: (Dict new at: 'headers' put: headers) |
put:body: | Primitive | url String - URL to put to, body String - request body | String - response body, or nil on error | Http put: 'https://api.example.com/item/1' body: '{"name": "Bob"}' |
put:body:options: | Primitive | url String - URL to put to, body String - request body, options Dict - options with 'headers' key | String - response body, or nil on error | Http put: url body: json options: opts |
delete: | Primitive | url String - URL to delete | String - response body, or nil on error | Http delete: 'https://api.example.com/item/1' |
delete:options: | Primitive | url String - URL to delete, options Dict - options with 'headers' key | String - response body, or nil on error | Http delete: url options: opts |
get:headers: | Primitive | url String - URL to fetch, headers Dict - custom headers (DEPRECATED: use get:options: instead) | String - response body, or nil on error | Http get: url headers: (Dict new at: 'Authorization' put: 'Bearer token') |
post:body:headers: | Primitive | url String - URL to post to, body String - request body, headers Dict - custom headers (DEPRECATED: use post:body:options: instead) | String - response body, or nil on error | Http post: url body: json headers: headers |
put:body:headers: | Primitive | url String - URL to put to, body String - request body, headers Dict - custom headers (DEPRECATED: use put:body:options: instead) | String - response body, or nil on error | Http put: url body: json headers: headers |
delete:headers: | Primitive | url String - URL to delete, headers Dict - custom headers (DEPRECATED: use delete:options: instead) | String - response body, or nil on error | Http delete: url headers: headers |
getWithHeaders: | Primitive | url String - URL to fetch | Dict - dict with 'headers' (Dict) and 'body' (String) keys | (Http getWithHeaders: url) at: 'headers' |
Integer
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
sin | Primitive | - | Float - sine value | 0 sin "=> 0.0" |
cos | Primitive | - | Float - cosine value | 0 cos "=> 1.0" |
tan | Primitive | - | Float - tangent value | 0 tan "=> 0.0" |
log | Primitive | - | Float - natural logarithm | 10 log "=> 2.302..." |
exp | Primitive | - | Float - e raised to this power | 1 exp "=> 2.718..." |
sqrt | Primitive | - | Float - square root | 16 sqrt "=> 4.0" |
log10 | Primitive | - | Float - base-10 logarithm | 100 log10 "=> 2.0" |
raisedTo: | Primitive | exponent Number - power to raise to | Float - result | 2 raisedTo: 10 "=> 1024.0" |
floor | Primitive | - | Integer - self (integers are already whole) | 42 floor "=> 42" |
ceiling | Primitive | - | Integer - self (integers are already whole) | 42 ceiling "=> 42" |
rounded | Primitive | - | Integer - self (integers are already whole) | 42 rounded "=> 42" |
bitShift: | Primitive | count Integer - number of bits to shift (positive=left, negative=right) | Integer - shifted value | 1 bitShift: 10 "=> 1024" |
bitAnd: | Primitive | other Integer - value to AND with | Integer - bitwise AND result | 7 bitAnd: 3 "=> 3" |
bitOr: | Primitive | other Integer - value to OR with | Integer - bitwise OR result | 4 bitOr: 3 "=> 7" |
bitXor: | Primitive | other Integer - value to XOR with | Integer - bitwise XOR result | 7 bitXor: 3 "=> 4" |
asString | Primitive | - | String - decimal string representation | 42 asString "=> '42'" |
asCharacter | Primitive | - | Character - Unicode character for this code point | 65 asCharacter "=> $A" |
format: | Primitive | pattern String - strftime format pattern | String - formatted local time | DateTime now format: '%Y-%m-%d' "=> '2026-01-17'" |
formatUtc: | Primitive | pattern String - strftime format pattern | String - formatted UTC time | DateTime now formatUtc: '%Y-%m-%d' "=> '2026-01-17'" |
@ | Primitive | y Number - y coordinate | Point - new Point with self as x | 10 @ 20 "=> Point(10, 20)" |
Interval
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
start | Primitive | - | Integer - start value | (1 to: 10) start "=> 1" |
stop | Primitive | - | Integer - end value | (1 to: 10) stop "=> 10" |
step | Primitive | - | Integer - step value | (1 to: 10 by: 2) step "=> 2" |
size | Primitive | - | Integer - number of elements | (1 to: 10) size "=> 10" |
asArray | Primitive | - | Array - interval as array | (1 to: 5) asArray "=> #(1 2 3 4 5)" |
includes: | Primitive | value Integer - value to check | Boolean - true if in interval | (1 to: 10) includes: 5 "=> true" |
by: | Primitive | step Integer - new step value | Interval - new interval with step | (1 to: 10) by: 2 |
Interval class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
from:to: | Primitive | start Integer - start value, end Integer - end value | Interval - new interval with step 1 | Interval from: 1 to: 10 |
from:to:by: | Primitive | start Integer - start value, end Integer - end value, step Integer - step value | Interval - new interval with custom step | Interval from: 1 to: 10 by: 2 |
Json class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
parse: | Primitive | string String - JSON string to parse | Any - parsed value (Dict, Array, String, Integer, Float, Boolean, nil) | Json parse: '{"name": "Alice", "age": 30}' |
generate: | Primitive | value Any - value to serialize | String - JSON string | Json generate: (Dict new at: 'name' put: 'Alice') |
generate:options: | Primitive | value Any - value to serialize, options Dict - options (e.g., 'pretty' -> true) | String - JSON string | Json generate: data options: (Dict new at: 'pretty' put: true) |
OrderedCollection
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
size | Primitive | - | Integer - number of elements | coll size |
add: | Primitive | value Any - value to append | self | coll add: 42 |
addFirst: | Primitive | value Any - value to prepend | self | coll addFirst: 1 |
removeFirst | Primitive | - | Any - removed first element | coll removeFirst |
removeLast | Primitive | - | Any - removed last element | coll removeLast |
remove: | Primitive | value Any - value to remove | Any - removed value, or nil if not found | coll remove: 42 |
at: | Primitive | index Integer - 1-based index | Any - element at index | coll at: 1 |
includes: | Primitive | value Any - value to search for | Boolean - true if found | coll includes: 42 |
first | Primitive | - | Any - first element | coll first |
last | Primitive | - | Any - last element | coll last |
asArray | Primitive | - | Array - elements as array | coll asArray |
copyFrom:to: | Primitive | start Integer - 1-based start index, end Integer - 1-based end index (inclusive) | OrderedCollection - new sliced collection | coll copyFrom: 2 to: 4 |
OrderedCollection class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
new | Primitive | - | OrderedCollection - new empty collection | OrderedCollection new |
Path class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
basename: | Primitive | path String - file path | String - file name without directory | Path basename: '/home/user/file.txt' "=> 'file.txt'" |
dirname: | Primitive | path String - file path | String - directory part of path | Path dirname: '/home/user/file.txt' "=> '/home/user'" |
extension: | Primitive | path String - file path | String - file extension (without dot) | Path extension: 'file.txt' "=> 'txt'" |
join:with: | Primitive | base String - base path, child String - child path | String - joined path | Path join: '/home' with: 'user' "=> '/home/user'" |
absolute: | Primitive | path String - relative path | String - absolute path | Path absolute: 'file.txt' |
exists: | Primitive | path String - path to check | Boolean - true if path exists | Path exists: '/tmp' |
isDirectory: | Primitive | path String - path to check | Boolean - true if path is a directory | Path isDirectory: '/tmp' |
Point
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
x | Primitive | - | Number - x coordinate | (10 @ 20) x "=> 10" |
y | Primitive | - | Number - y coordinate | (10 @ 20) y "=> 20" |
x: | Primitive | value Number - new x coordinate | self | point x: 30 |
y: | Primitive | value Number - new y coordinate | self | point y: 40 |
Process class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
run:args: | Primitive | command String - command to run, args Array - array of arguments | Integer - exit code | Process run: 'ls' args: #('-la') |
output:args: | Primitive | command String - command to run, args Array - array of arguments | String - captured stdout output | Process output: 'echo' args: #('hello') |
Random class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
next | Primitive | - | Float - random float between 0.0 and 1.0 | Random next |
nextInt: | Primitive | max Integer - exclusive upper bound | Integer - random integer from 0 to max-1 | Random nextInt: 100 |
Set
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
add: | Primitive | value Any - value to add | self | set add: 42 |
includes: | Primitive | value Any - value to check | Boolean - true if member | set includes: 42 |
size | Primitive | - | Integer - number of elements | set size |
remove: | Primitive | value Any - value to remove | Any - removed value, or nil | set remove: 42 |
union: | Primitive | other Set - set to union with | Set - new set with all elements | set1 union: set2 |
intersection: | Primitive | other Set - set to intersect with | Set - new set with common elements | set1 intersection: set2 |
difference: | Primitive | other Set - set to subtract | Set - new set with elements not in other | set1 difference: set2 |
asArray | Primitive | - | Array - elements as array | set asArray |
Set class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
new | Primitive | - | Set - new empty set | Set new |
Sha2 class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
hash256: | Primitive | data String - data to hash | String - SHA-256 hash as hex string | Sha2 hash256: 'hello' |
sha256: | Primitive | data String - data to hash (alias for hash256:) | String - SHA-256 hash as hex string | Sha2 sha256: 'hello' |
hash512: | Primitive | data String - data to hash | String - SHA-512 hash as hex string | Sha2 hash512: 'hello' |
sha512: | Primitive | data String - data to hash (alias for hash512:) | String - SHA-512 hash as hex string | Sha2 sha512: 'hello' |
Sqlite
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
execute: | Primitive | sql String - SQL statement to execute | Boolean - true on success | db execute: 'CREATE TABLE users (id INTEGER, name TEXT)' |
execute:with: | Primitive | sql String - SQL statement with ? placeholders, params Array - parameter values | Boolean - true on success | db execute: 'INSERT INTO users VALUES (?, ?)' with: #(1 'Alice') |
query: | Primitive | sql String - SELECT statement | Array - array of Dict rows, or nil on error | db query: 'SELECT * FROM users' |
query:with: | Primitive | sql String - SELECT statement with ? placeholders, params Array - parameter values | Array - array of Dict rows, or nil on error | db query: 'SELECT * FROM users WHERE id = ?' with: #(1) |
queryScalar: | Primitive | sql String - SELECT returning single value | Any - scalar value, or nil on error | db queryScalar: 'SELECT COUNT(*) FROM users' |
queryScalar:with: | Primitive | sql String - SELECT with ? placeholders returning single value, params Array - parameter values | Any - scalar value, or nil on error | db queryScalar: 'SELECT name FROM users WHERE id = ?' with: #(1) |
Sqlite class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
open: | Primitive | path String - database file path (':memory:' for in-memory DB) | Sqlite - database connection, or nil on error | Sqlite open: 'mydb.sqlite' |
openWith: | Primitive | path String - database file path (alias for open:) | Sqlite - database connection, or nil on error | Sqlite openWith: ':memory:' |
Stdin class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
readLine | Primitive | - | String - one line from standard input | Stdin readLine |
readAll | Primitive | - | String - all remaining input from stdin | Stdin readAll |
String
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
size | Primitive | - | Integer - number of characters | 'hello' size "=> 5" |
at: | Primitive | index Integer - 1-based index | Character - character at index | 'hello' at: 2 "=> $e" |
, | Primitive | other String - string to append | String - concatenated string | 'hello' , ' world' "=> 'hello world'" |
split: | Primitive | delimiter String - delimiter to split on | Array - array of substrings | 'a,b,c' split: ',' "=> #('a' 'b' 'c')" |
trim | Primitive | - | String - string with leading/trailing whitespace removed | ' hello ' trim "=> 'hello'" |
asUppercase | Primitive | - | String - uppercase version | 'hello' asUppercase "=> 'HELLO'" |
asLowercase | Primitive | - | String - lowercase version | 'HELLO' asLowercase "=> 'hello'" |
includes: | Primitive | substring String - substring to search for | Boolean - true if contains substring | 'hello' includes: 'ell' "=> true" |
beginsWith: | Primitive | prefix String - prefix to check | Boolean - true if starts with prefix | 'hello' beginsWith: 'he' "=> true" |
endsWith: | Primitive | suffix String - suffix to check | Boolean - true if ends with suffix | 'hello' endsWith: 'lo' "=> true" |
copyFrom:to: | Primitive | start Integer - 1-based start index, end Integer - 1-based end index (inclusive) | String - substring | 'hello' copyFrom: 2 to: 4 "=> 'ell'" |
replace:with: | Primitive | old String - substring to replace (first occurrence), new String - replacement string | String - new string with replacement | 'hello' replace: 'l' with: 'L' "=> 'heLlo'" |
replaceAll:with: | Primitive | old String - substring to replace (all occurrences), new String - replacement string | String - new string with all replacements | 'hello' replaceAll: 'l' with: 'L' "=> 'heLLo'" |
* | Primitive | count Integer - number of repetitions | String - repeated string | 'ab' * 3 "=> 'ababab'" |
match: | Primitive | pattern String - regex pattern | Boolean - true if matches | 'hello' match: 'h.*o' "=> true" |
matchGroups: | Primitive | pattern String - regex pattern with capture groups | Array - array of captured groups, or nil if no match | 'hello123' matchGroups: '([a-z]+)([0-9]+)' "=> #('hello123' 'hello' '123')" |
extract: | Primitive | pattern String - regex pattern | Array - all matches as array of strings | 'a1b2c3' extract: '[0-9]+' "=> #('1' '2' '3')" |
asInteger | Primitive | - | Integer - parsed integer value | '42' asInteger "=> 42" |
asNumber | Primitive | - | Number - parsed float value | '3.14' asNumber "=> 3.14" |
asString | Primitive | - | String - self | 'hello' asString "=> 'hello'" |
displayWidth | Primitive | - | Integer - display width (handles CJK characters) | 'hello' displayWidth "=> 5" |
findString:startingAt: | Primitive | substring String - substring to find, start Integer - 1-based start position | Integer - 1-based index, or 0 if not found | 'hello' findString: 'l' startingAt: 1 "=> 3" |
indexOf: | Primitive | substring String - substring to find | Integer - 1-based index, or 0 if not found | 'hello' indexOf: 'l' "=> 3" |
regexEscape | Primitive | - | String - string with regex metacharacters escaped | 'a.b*c' regexEscape "=> 'a\\.b\\*c'" |
StringStream
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
nextPutAll: | Primitive | string String - string to append | self | stream nextPutAll: 'Hello' |
contents | Primitive | - | String - accumulated string contents | stream contents |
size | Primitive | - | Integer - current length of contents | stream size |
reset | Primitive | - | self - clears the buffer | stream reset |
nextPut: | Primitive | char Character - character to append | self | stream nextPut: $A |
StringStream class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
new | Primitive | - | StringStream - new empty string stream | StringStream new |
new: | Primitive | initialCapacity Integer - initial buffer capacity | StringStream - new string stream with capacity | StringStream new: 1024 |
System class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
args | Primitive | - | Array - command line arguments | System args |
heapSize | Primitive | - | Integer - current heap size in bytes | System heapSize |
platform | Primitive | - | String - platform name ('windows', 'linux', 'macos') | System platform |
exit: | Primitive | code Integer - exit code | never returns (process exits) | System exit: 0 |
nilTolerantEnter | Primitive | - | nil - enters nil-tolerant mode (nil message sends return nil) | System nilTolerantEnter |
nilTolerantLeave | Primitive | - | nil - leaves nil-tolerant mode | System nilTolerantLeave |
isNilTolerant | Primitive | - | Boolean - true if in nil-tolerant mode | System isNilTolerant |
performGC | Primitive | - | nil - triggers garbage collection | System performGC |
gc | Primitive | - | nil - alias for performGC | System gc |
gcThreshold | Primitive | - | Integer - current GC threshold in bytes | System gcThreshold |
gcThreshold: | Primitive | bytes Integer - new GC threshold in bytes | nil | System gcThreshold: 1000000 |
onInterrupt: | Primitive | block Block - handler to call on SIGINT (Ctrl+C) | nil | System onInterrupt: [ 'Interrupted!' printNl. System exit: 1 ] |
clearInterruptHandler | Primitive | - | nil - removes the interrupt handler | System clearInterruptHandler |
classNamed: | Primitive | name String - class name to look up | Class|nil - the class object, or nil if not found | System classNamed: 'String' |
allClasses | Primitive | - | Array - array of all class names | System allClasses |
Tcp class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
connect:port: | Primitive | host String - hostname or IP address, port Integer - port number | TcpStream - connection, or nil on error | Tcp connect: 'localhost' port: 8080 |
connect:port:timeout: | Primitive | host String - hostname or IP address, port Integer - port number, timeout Integer - timeout in milliseconds | TcpStream - connection, or nil on timeout/error | Tcp connect: 'localhost' port: 8080 timeout: 5000 |
TcpListener
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
accept | Primitive | - | TcpStream - accepted connection (blocking), or nil on error | listener accept |
close | Primitive | - | Boolean - true (listener closes on drop) | listener close |
TcpListener class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
listen: | Primitive | port Integer - port to listen on (binds to 0.0.0.0) | TcpListener - listener, or nil on error | TcpListener listen: 8080 |
listenOn:port: | Primitive | address String - address to bind (e.g., '127.0.0.1'), port Integer - port to listen on | TcpListener - listener, or nil on error | TcpListener listenOn: '127.0.0.1' port: 8080 |
TcpStream
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
send: | Primitive | data String|ByteArray - data to send | Integer - bytes sent, or nil on error | stream send: 'GET / HTTP/1.0\r\n\r\n' |
recv: | Primitive | maxBytes Integer - maximum bytes to receive | ByteArray - received data, or nil on error/closed | stream recv: 4096 |
recv | Primitive | - | ByteArray - received data (default 4096 bytes max), or nil | stream recv |
recvLine | Primitive | - | String - line without newline, or nil on error/closed | stream recvLine |
close | Primitive | - | Boolean - true on success | stream close |
Time class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
millisecondClock | Primitive | - | Integer - milliseconds since VM startup (monotonic) | Time millisecondClock |
nanosecondClock | Primitive | - | Integer - nanoseconds since VM startup (monotonic) | Time nanosecondClock |
Toml class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
parse: | Primitive | string String - TOML string to parse | Dict - parsed TOML as dictionary | Toml parse: '[section]\nkey = "value"' |
Yaml class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
parse: | Primitive | string String - YAML string to parse | Any - parsed value | Yaml parse: 'name: Alice\nage: 30' |
Standard Library
Classes defined in lib/*.st.
Ansi class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
esc | Smalltalk | - | String - ESC character | Ansi esc |
csi | Smalltalk | - | String - CSI sequence (ESC[) | Ansi csi |
reset | Smalltalk | - | String - ANSI reset sequence | Ansi reset |
wrap: aString with: code | Smalltalk | aString String - text to wrap, code String - ANSI code | String - wrapped with ANSI escape | Ansi wrap: 'hello' with: '31' |
Array
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
product | Smalltalk | - | Number - product of all elements | #(1 2 3 4) product => 24 |
first | Smalltalk | - | Object - first element | #(a b c) first |
last | Smalltalk | - | Object - last element | #(a b c) last |
allButFirst | Smalltalk | - | Array - all elements except first | #(1 2 3) allButFirst |
allButLast | Smalltalk | - | Array - all elements except last | #(1 2 3) allButLast |
take: count | Smalltalk | count Integer - number of elements to take | Array - first count elements | #(1 2 3 4 5) take: 3 |
drop: count | Smalltalk | count Integer - number of elements to skip | Array - remaining elements after skip | #(1 2 3 4 5) drop: 2 |
copy | Smalltalk | - | Array - shallow copy | #(1 2 3) copy |
copyWith: element | Smalltalk | element Object - element to append | Array - new array with element at end | #(1 2) copyWith: 3 |
copyWithout: element | Smalltalk | element Object - element to remove | Array - new array without element | #(1 2 3 2) copyWithout: 2 |
indexOf: element | Smalltalk | element Object - element to find | Integer - 1-based index or 0 if not found | #(a b c) indexOf: b |
flatten | Smalltalk | - | Array - flattened by one level | #((1 2) (3 4)) flatten |
unique | Smalltalk | - | Array - with duplicates removed | #(1 2 1 3 2) unique |
reversed | Smalltalk | - | Array - elements in reverse order | #(1 2 3) reversed |
zip: other | Smalltalk | other Array - array to zip with | Array - array of pairs | #(1 2 3) zip: #(a b c) |
sort | Smalltalk | - | Array - sorted in ascending order | #(3 1 4 1 5) sort |
sortBy: aBlock | Smalltalk | aBlock Block - comparator [:a :b | a < b] | Array - sorted by comparator | #(3 1 4) sortBy: [:a :b | a > b] |
Array class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
withAll: aCollection | Smalltalk | aCollection Collection - source collection | Array - new array with all elements | Array withAll: (1 to: 5) |
with: anObject | Smalltalk | anObject Object - the element | Array - single-element array | Array with: 42 |
with: first with: second | Smalltalk | first Object - first element, second Object - second element | Array - two-element array | Array with: 1 with: 2 |
CLI.ArgParser
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
name: aName | Smalltalk | aName String - program name | ArgParser - self for chaining | parser name: 'my-tool' |
description: desc | Smalltalk | desc String - program description | ArgParser - self for chaining | parser description: 'A useful tool' |
flag: longName short: shortName description: desc | Smalltalk | longName String - long flag name, shortName String - short flag name, desc String - description | ArgParser - self for chaining | parser flag: 'verbose' short: 'v' description: 'Verbose' |
option: longName short: shortName description: desc | Smalltalk | longName String - long option name, shortName String - short option name, desc String - description | ArgParser - self for chaining | parser option: 'output' short: 'o' description: 'Output file' |
positional: aName description: desc | Smalltalk | aName String - positional arg name, desc String - description | ArgParser - self for chaining | parser positional: 'input' description: 'Input file' |
parse: args | Smalltalk | args Array - command line arguments | ParseResult - parsed result | parser parse: System args |
CLI.ParseResult
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
isSuccess | Smalltalk | - | Boolean - true if parse succeeded | result isSuccess |
flag: name | Smalltalk | name String - flag name | Boolean - true if flag was set | result flag: 'verbose' |
option: name | Smalltalk | name String - option name | String - option value or nil | result option: 'output' |
positional: name | Smalltalk | name String - positional arg name | String - positional value or nil | result positional: 'input' |
extras | Smalltalk | - | Array - extra positional arguments | result extras |
Collection
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
isEmpty | Smalltalk | - | Boolean - true if collection has no elements | #() isEmpty |
notEmpty | Smalltalk | - | Boolean - true if collection has at least one element | #(1 2 3) notEmpty |
second | Smalltalk | - | Object - the second element | #(a b c) second |
third | Smalltalk | - | Object - the third element | #(a b c) third |
do: aBlock | Smalltalk | aBlock Block - block to evaluate for each element | nil | #(1 2 3) do: [:x | x printNl] |
collect: aBlock | Smalltalk | aBlock Block - transformation block | Collection - new collection with transformed elements | #(1 2 3) collect: [:x | x * 2] |
select: aBlock | Smalltalk | aBlock Block - predicate block | Collection - elements where block returns true | #(1 2 3 4) select: [:x | x > 2] |
reject: aBlock | Smalltalk | aBlock Block - predicate block | Collection - elements where block returns false | #(1 2 3 4) reject: [:x | x > 2] |
detect: aBlock | Smalltalk | aBlock Block - predicate block | Object - first matching element or nil | #(1 2 3 4) detect: [:x | x > 2] |
detect: aBlock ifNone: exceptionBlock | Smalltalk | aBlock Block - predicate block, exceptionBlock Block - block to evaluate if not found | Object - first match or exceptionBlock result | #(1 2 3) detect: [:x | x > 5] ifNone: [0] |
inject: initialValue into: aBlock | Smalltalk | initialValue Object - initial accumulator value, aBlock Block - two-arg block [:acc :each | ...] | Object - final accumulated value | #(1 2 3) inject: 0 into: [:sum :x | sum + x] |
doWithIndex: aBlock | Smalltalk | aBlock Block - two-arg block [:elem :index | ...] | nil | #(a b c) doWithIndex: [:e :i | (i,e) printNl] |
ifEmpty: aBlock | Smalltalk | aBlock Block - block to evaluate if empty | Object - block result or self | #() ifEmpty: ['none'] |
ifNotEmpty: aBlock | Smalltalk | aBlock Block - block to evaluate with self | Object - block result or self | #(1 2) ifNotEmpty: [:c | c size] |
count: aBlock | Smalltalk | aBlock Block - predicate block | Integer - count of matches | #(1 2 3 4) count: [:x | x > 2] |
includes: anObject | Smalltalk | anObject Object - object to find | Boolean - true if found | #(1 2 3) includes: 2 |
join: separator | Smalltalk | separator String - separator between elements | String - joined elements | #(1 2 3) join: ', ' |
anySatisfy: aBlock | Smalltalk | aBlock Block - predicate block | Boolean - true if any match | #(1 2 3) anySatisfy: [:x | x > 2] |
allSatisfy: aBlock | Smalltalk | aBlock Block - predicate block | Boolean - true if all match | #(2 4 6) allSatisfy: [:x | x even] |
noneSatisfy: aBlock | Smalltalk | aBlock Block - predicate block | Boolean - true if none match | #(1 3 5) noneSatisfy: [:x | x even] |
groupBy: keyBlock | Smalltalk | keyBlock Block - block to compute key | Dictionary - grouped elements | #(1 2 3 4) groupBy: [:x | x even] |
tally | Smalltalk | - | Dictionary - element occurrence counts | #(a b a c) tally |
Collection class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
withAll: aCollection | Smalltalk | aCollection Collection - source collection | Collection - new collection with all elements | OrderedCollection withAll: #(1 2 3) |
Core.Association class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
key: aKey value: aValue | Smalltalk | aKey Object - the key, aValue Object - the value | Association - key-value pair | Association key: 'name' value: 'John' |
Core.Block
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
timeToRun | Smalltalk | - | Integer - milliseconds taken to execute the block | [ 1000 timesRepeat: [ 1 + 1 ] ] timeToRun |
Core.Exception class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
signal: aString | Smalltalk | aString String - exception message | - raises exception | Exception signal: 'Error occurred' |
Core.Object
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
error: aString | Smalltalk | aString String - error message | - raises Error exception | self error: 'Something went wrong' |
-> anObject | Smalltalk | anObject Object - the value | Association - self as key, anObject as value | 'name' -> 'John' |
Core.Object class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
basicNew | Smalltalk | - | Object - uninitialized instance | Point basicNew |
new | Smalltalk | - | Object - new initialized instance | Point new |
Core.Path class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
stem: aPath | Smalltalk | aPath String - file path | String - filename without extension | Path stem: 'foo/bar.txt' |
Core.String
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
stripAnsi | Smalltalk | - | String - with ANSI escape sequences removed | 'hello' red stripAnsi |
displayWidth | Smalltalk | - | Integer - display width accounting for full-width chars | 'hello' displayWidth |
splitOn: aDelimiter | Smalltalk | aDelimiter String - delimiter to split on | Array - array of substrings | 'a,b,c' splitOn: ',' |
Core.String class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
join: aCollection with: aDelimiter | Smalltalk | aCollection Collection - elements to join, aDelimiter String - separator between elements | String - joined string | String join: #(a b c) with: ', ' |
Core.Time class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
millisecondsToRun: aBlock | Smalltalk | aBlock Block - block to measure | Integer - milliseconds taken to execute the block | Time millisecondsToRun: [ 1000 timesRepeat: [ 1 + 1 ] ] |
Dictionary
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
do: aBlock | Smalltalk | aBlock Block - block for each value | nil | dict do: [:v | v printNl] |
keysAndValuesDo: aBlock | Smalltalk | aBlock Block - two-arg block [:key :value | ...] | nil | dict keysAndValuesDo: [:k :v | k printNl] |
hasKey: key | Smalltalk | key Object - key to check | Boolean - true if key exists | dict hasKey: 'name' |
at: key ifAbsent: absentBlock | Smalltalk | key Object - key to look up, absentBlock Block - block if key not found | Object - value or block result | dict at: 'x' ifAbsent: [0] |
at: key ifAbsentPut: aBlock | Smalltalk | key Object - key to look up, aBlock Block - block to compute and store if absent | Object - existing or new value | dict at: 'x' ifAbsentPut: [0] |
Integer
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
even | Smalltalk | - | Boolean - true if even | 4 even |
odd | Smalltalk | - | Boolean - true if odd | 5 odd |
Maybe class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
value: aBlock | Smalltalk | aBlock Block - block to execute in nil-tolerant mode | Object - block result or nil | Maybe value: [dict at: 'key' at: 'sub'] |
Number
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
abs | Smalltalk | - | Number - absolute value | -5 abs |
min: other | Smalltalk | other Number - value to compare | Number - smaller value | 3 min: 5 |
max: other | Smalltalk | other Number - value to compare | Number - larger value | 3 max: 5 |
Shell.Sh class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
run: commandString | Smalltalk | commandString String - shell command to execute | Integer - exit code (0 = success) | Sh run: 'git status' |
output: commandString | Smalltalk | commandString String - shell command to execute | String - stdout content | (Sh output: 'echo hello') printNl |
lines: commandString | Smalltalk | commandString String - shell command to execute | Array - array of output lines | (Sh lines: 'ls') do: [:l | l printNl] |
success: commandString | Smalltalk | commandString String - shell command to execute | Boolean - true if exit code is 0 | (Sh success: 'test -f README.md') ifTrue: ['exists' printNl] |
String
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
red | Smalltalk | - | String - red colored text | 'error' red |
green | Smalltalk | - | String - green colored text | 'ok' green |
yellow | Smalltalk | - | String - yellow colored text | 'warning' yellow |
blue | Smalltalk | - | String - blue colored text | 'info' blue |
bold | Smalltalk | - | String - bold text | 'important' bold |
underline | Smalltalk | - | String - underlined text | 'link' underline |
lines | Smalltalk | - | Array - array of lines | 'a\nb\nc' lines |
words | Smalltalk | - | Array - array of words split by whitespace | 'hello world' words |
repeat: count | Smalltalk | count Integer - number of repetitions | String - repeated string | 'ab' repeat: 3 |
isBlank | Smalltalk | - | Boolean - true if empty or whitespace only | ' ' isBlank |
trimLeft | Smalltalk | - | String - with leading whitespace removed | ' hello' trimLeft |
trimRight | Smalltalk | - | String - with trailing whitespace removed | 'hello ' trimRight |
includes: aString | Smalltalk | aString String - substring to find | Boolean - true if substring exists | 'hello world' includes: 'wor' |
format: collection | Smalltalk | collection Array - values to substitute | String - with {1}, {2}, etc replaced | 'Hello {1}!' format: #('World') |
Generated by tools/generate_api_grammar.st