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

Standard Library


Built-in Classes

Array

MethodTypeParametersReturnsExample
sizePrimitive-Integer - number of elements#(1 2 3) size "=> 3"
at:Primitiveindex Integer - 1-based indexAny - element at index, or nil if out of bounds#(10 20 30) at: 2 "=> 20"
at:put:Primitiveindex Integer - 1-based index, value Any - value to storeAny - the stored valuearr at: 1 put: 'hello'
firstPrimitive-Any - first element, or nil if empty#(10 20 30) first "=> 10"
lastPrimitive-Any - last element, or nil if empty#(10 20 30) last "=> 30"
add:Primitivevalue Any - value to appendselfarr add: 42
includes:Primitivevalue Any - value to search forBoolean - true if found#(1 2 3) includes: 2 "=> true"
sortPrimitive-Array - new sorted array#(3 1 2) sort "=> #(1 2 3)"
indexOf:Primitivevalue Any - value to search forInteger - 1-based index, or 0 if not found#(10 20 30) indexOf: 20 "=> 2"
join:Primitiveseparator String - separator between elementsString - joined string#('a' 'b' 'c') join: '-' "=> 'a-b-c'"
,Primitiveother Array - array to appendArray - new concatenated array#(1 2) , #(3 4) "=> #(1 2 3 4)"
copyFrom:to:Primitivestart 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)"
asStringPrimitive-String - string representation#(1 2 3) asString "=> '#(1 2 3)'"
sumPrimitive-Number - sum of all numeric elements#(1 2 3 4 5) sum "=> 15"
maxPrimitive-Object - maximum element or nil if empty#(3 1 4 1 5) max "=> 5"
minPrimitive-Object - minimum element or nil if empty#(3 1 4 1 5) min "=> 1"
averagePrimitive-Number - average of all numeric elements (0 if empty)#(1 2 3 4 5) average "=> 3"

Base64 class

MethodTypeParametersReturnsExample
encode:Primitivedata String|ByteArray - data to encodeString - base64 encoded stringBase64 encode: 'Hello, World!'
decode:Primitivestring String - base64 string to decodeString - decoded dataBase64 decode: 'SGVsbG8sIFdvcmxkIQ=='

ByteArray

MethodTypeParametersReturnsExample
at:Primitiveindex Integer - 1-based indexInteger - byte value (0-255)bytes at: 1
at:put:Primitiveindex Integer - 1-based index, value Integer - byte value (0-255)Integer - stored valuebytes at: 1 put: 255
sizePrimitive-Integer - number of bytesbytes size
asStringPrimitive-String - UTF-8 string from bytesbytes asString
copyFrom:to:Primitivestart Integer - 1-based start index, end Integer - 1-based end index (inclusive)ByteArray - new sliced byte arraybytes copyFrom: 1 to: 10

ByteArray class

MethodTypeParametersReturnsExample
new:Primitivesize Integer - number of bytesByteArray - new byte array filled with zerosByteArray new: 10
fromString:Primitivestring String - string to convertByteArray - UTF-8 bytes of stringByteArray fromString: 'hello'

Character

MethodTypeParametersReturnsExample
isLetterPrimitive-Boolean - true if alphabetic$a isLetter "=> true"
isDigitPrimitive-Boolean - true if numeric digit$5 isDigit "=> true"
isAlphanumericPrimitive-Boolean - true if letter or digit$a isAlphanumeric "=> true"
isUppercasePrimitive-Boolean - true if uppercase letter$A isUppercase "=> true"
isLowercasePrimitive-Boolean - true if lowercase letter$a isLowercase "=> true"
isWhitespacePrimitive-Boolean - true if whitespace character$ isWhitespace "=> true"
asUppercasePrimitive-Character - uppercase version$a asUppercase "=> $A"
asLowercasePrimitive-Character - lowercase version$A asLowercase "=> $a"
asIntegerPrimitive-Integer - Unicode code point$A asInteger "=> 65"
asStringPrimitive-String - single-character string$A asString "=> 'A'"
=Primitiveother Character - character to compareBoolean - true if equal$a = $a "=> true"
<Primitiveother Character - character to compareBoolean - true if less than$a < $b "=> true"
<=Primitiveother Character - character to compareBoolean - true if less than or equal$a <= $a "=> true"
>Primitiveother Character - character to compareBoolean - true if greater than$b > $a "=> true"
>=Primitiveother Character - character to compareBoolean - true if greater than or equal$a >= $a "=> true"

ChildProcess

MethodTypeParametersReturnsExample
isFinishedPrimitive-Boolean - true if process has exitedchild isFinished
exitCodePrimitive-Integer|nil - exit code if finished, nil otherwisechild exitCode
waitPrimitive-Integer - wait for process to finish and return exit codechild wait
printPrimitive-selfchild print
printNlPrimitive-selfchild printNl

ChildProcess class

MethodTypeParametersReturnsExample
spawn:args:Primitivecommand String - command to spawn, args Array - array of argumentsChildProcess - spawned process handleChildProcess spawn: 'sleep' args: #('5')

Csv class

MethodTypeParametersReturnsExample
parse:Primitivestring String - CSV string to parseArray - array of rows (each row is an array of values)Csv parse: 'name,age\nAlice,30'
parse:options:Primitivestring String - CSV string to parse, options Dict - options ('headers' -> true for Dict rows)Array - parsed rowsCsv parse: 'name,age\nAlice,30' options: (Dict new at: 'headers' put: true)
reader:Primitivestring String - CSV string for streaming readCsvReader - streaming CSV readerCsv reader: (File read: 'data.csv')

CsvReader

MethodTypeParametersReturnsExample
nextPrimitive-Array|nil - next row, or nil at endreader next
atEndPrimitive-Boolean - true if no more rowsreader atEnd

DateTime class

MethodTypeParametersReturnsExample
nowPrimitive-Integer - current Unix timestamp in secondsDateTime now
parse:Primitivestring String - ISO 8601 date stringInteger - Unix timestampDateTime parse: '2024-01-15T10:30:00Z'

Dict

MethodTypeParametersReturnsExample
at:Primitivekey String|Symbol - key to look upAny - value for key, or nil if not founddict at: 'name' "=> 'Alice'"
at:put:Primitivekey String|Symbol - key to store, value Any - value to storeAny - the stored valuedict at: 'name' put: 'Bob'
keysPrimitive-Array - array of all keysdict keys "=> #('name' 'age')"
sizePrimitive-Integer - number of key-value pairsdict size "=> 2"
includesKey:Primitivekey String|Symbol - key to checkBoolean - true if key existsdict includesKey: 'name' "=> true"
removeKey:Primitivekey String|Symbol - key to removeAny - removed value, or nil if key not founddict removeKey: 'name'
valuesPrimitive-Array - array of all valuesdict values "=> #('Alice' 30)"
keysAndValuesPrimitive-Array - array of Association (key->value pairs)dict keysAndValues do: [:assoc | assoc key print. assoc value printNl]
asStringPrimitive-String - string representationdict asString "=> 'Dict(name->Alice age->30)'"

Dict class

MethodTypeParametersReturnsExample
newPrimitive-Dict - new empty dictionaryDict new

Directory class

MethodTypeParametersReturnsExample
entries:Primitivepath String - directory pathArray - array of entry names in the directoryDirectory entries: '.'

Env class

MethodTypeParametersReturnsExample
keysPrimitive-Array - array of all environment variable namesEnv keys
at:Primitivename String - environment variable nameString|nil - value or nil if not setEnv at: 'PATH'
at:put:Primitivename String - environment variable name, value String - value to setString - the valueEnv at: 'MY_VAR' put: 'value'

File class

MethodTypeParametersReturnsExample
read:Primitivepath String - file path to readString - file contentsFile read: 'data.txt'
read:encoding:Primitivepath String - file path to read, encoding String - encoding name ('utf-8', 'shift-jis', 'euc-jp', etc.)String - file contents decoded with specified encodingFile read: 'data.txt' encoding: 'shift-jis'
write:content:Primitivepath String - file path to write, content String - content to writetrue on successFile write: 'output.txt' content: 'Hello, World!'
exists:Primitivepath String - file path to checkBoolean - true if file existsFile exists: 'data.txt'
delete:Primitivepath String - file path to deletetrue on successFile delete: 'temp.txt'
glob:Primitivepattern String - glob pattern (e.g., '.txt', 'src/**/.rs')Array - array of matching file pathsFile glob: 'examples/*.st'
appendTo:content:Primitivepath String - file path to append to, content String - content to appendtrue on successFile appendTo: 'log.txt' content: 'New log entry'
mkdir:Primitivepath String - directory path to createtrue on successFile mkdir: 'new_folder'
copy:to:Primitivesource String - source file path, dest String - destination file pathtrue on successFile copy: 'original.txt' to: 'backup.txt'
move:to:Primitivesource String - source file path, dest String - destination file pathtrue on successFile move: 'old.txt' to: 'new.txt'
isDirectory:Primitivepath String - path to checkBoolean - true if path is a directoryFile isDirectory: 'src'

Float

MethodTypeParametersReturnsExample
sinPrimitive-Float - sine value3.14159 sin "=> ~0.0"
cosPrimitive-Float - cosine value0.0 cos "=> 1.0"
tanPrimitive-Float - tangent value0.0 tan "=> 0.0"
logPrimitive-Float - natural logarithm2.718 log "=> ~1.0"
expPrimitive-Float - e raised to this power1.0 exp "=> 2.718..."
sqrtPrimitive-Float - square root16.0 sqrt "=> 4.0"
log10Primitive-Float - base-10 logarithm100.0 log10 "=> 2.0"
raisedTo:Primitiveexponent Number - power to raise toFloat - result2.0 raisedTo: 10 "=> 1024.0"
floorPrimitive-Integer - largest integer <= self3.7 floor "=> 3"
ceilingPrimitive-Integer - smallest integer >= self3.2 ceiling "=> 4"
roundedPrimitive-Integer - nearest integer3.5 rounded "=> 4"
asStringPrimitive-String - string representation3.14 asString "=> '3.14'"
@Primitivey Number - y coordinatePoint - new Point with self as x10.5 @ 20.5 "=> Point(10.5, 20.5)"

Float class

MethodTypeParametersReturnsExample
piPrimitive-Float - mathematical constant piFloat pi "=> 3.14159..."
ePrimitive-Float - mathematical constant eFloat e "=> 2.71828..."
infinityPrimitive-Float - positive infinityFloat infinity "=> Infinity"
negativeInfinityPrimitive-Float - negative infinityFloat negativeInfinity "=> -Infinity"
nanPrimitive-Float - Not a NumberFloat nan "=> NaN"

Hmac class

MethodTypeParametersReturnsExample
sha256:key:Primitivedata String - data to authenticate, key String - secret keyString - HMAC-SHA256 as hex stringHmac sha256: 'message' key: 'secret'

Http class

MethodTypeParametersReturnsExample
get:Primitiveurl String - URL to fetchString - response body, or nil on errorHttp get: 'https://api.example.com/data'
get:options:Primitiveurl String - URL to fetch, options Dict - options with 'headers' key for custom headersString - response body, or nil on errorHttp get: 'https://api.example.com' options: (Dict new at: 'headers' put: headers)
post:body:Primitiveurl String - URL to post to, body String - request body (typically JSON)String - response body, or nil on errorHttp post: 'https://api.example.com' body: '{"name": "Alice"}'
post:body:options:Primitiveurl String - URL to post to, body String - request body, options Dict - options with 'headers' keyString - response body, or nil on errorHttp post: url body: json options: (Dict new at: 'headers' put: headers)
put:body:Primitiveurl String - URL to put to, body String - request bodyString - response body, or nil on errorHttp put: 'https://api.example.com/item/1' body: '{"name": "Bob"}'
put:body:options:Primitiveurl String - URL to put to, body String - request body, options Dict - options with 'headers' keyString - response body, or nil on errorHttp put: url body: json options: opts
delete:Primitiveurl String - URL to deleteString - response body, or nil on errorHttp delete: 'https://api.example.com/item/1'
delete:options:Primitiveurl String - URL to delete, options Dict - options with 'headers' keyString - response body, or nil on errorHttp delete: url options: opts
get:headers:Primitiveurl String - URL to fetch, headers Dict - custom headers (DEPRECATED: use get:options: instead)String - response body, or nil on errorHttp get: url headers: (Dict new at: 'Authorization' put: 'Bearer token')
post:body:headers:Primitiveurl 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 errorHttp post: url body: json headers: headers
put:body:headers:Primitiveurl 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 errorHttp put: url body: json headers: headers
delete:headers:Primitiveurl String - URL to delete, headers Dict - custom headers (DEPRECATED: use delete:options: instead)String - response body, or nil on errorHttp delete: url headers: headers
getWithHeaders:Primitiveurl String - URL to fetchDict - dict with 'headers' (Dict) and 'body' (String) keys(Http getWithHeaders: url) at: 'headers'

Integer

MethodTypeParametersReturnsExample
sinPrimitive-Float - sine value0 sin "=> 0.0"
cosPrimitive-Float - cosine value0 cos "=> 1.0"
tanPrimitive-Float - tangent value0 tan "=> 0.0"
logPrimitive-Float - natural logarithm10 log "=> 2.302..."
expPrimitive-Float - e raised to this power1 exp "=> 2.718..."
sqrtPrimitive-Float - square root16 sqrt "=> 4.0"
log10Primitive-Float - base-10 logarithm100 log10 "=> 2.0"
raisedTo:Primitiveexponent Number - power to raise toFloat - result2 raisedTo: 10 "=> 1024.0"
floorPrimitive-Integer - self (integers are already whole)42 floor "=> 42"
ceilingPrimitive-Integer - self (integers are already whole)42 ceiling "=> 42"
roundedPrimitive-Integer - self (integers are already whole)42 rounded "=> 42"
bitShift:Primitivecount Integer - number of bits to shift (positive=left, negative=right)Integer - shifted value1 bitShift: 10 "=> 1024"
bitAnd:Primitiveother Integer - value to AND withInteger - bitwise AND result7 bitAnd: 3 "=> 3"
bitOr:Primitiveother Integer - value to OR withInteger - bitwise OR result4 bitOr: 3 "=> 7"
bitXor:Primitiveother Integer - value to XOR withInteger - bitwise XOR result7 bitXor: 3 "=> 4"
asStringPrimitive-String - decimal string representation42 asString "=> '42'"
asCharacterPrimitive-Character - Unicode character for this code point65 asCharacter "=> $A"
format:Primitivepattern String - strftime format patternString - formatted local timeDateTime now format: '%Y-%m-%d' "=> '2026-01-17'"
formatUtc:Primitivepattern String - strftime format patternString - formatted UTC timeDateTime now formatUtc: '%Y-%m-%d' "=> '2026-01-17'"
@Primitivey Number - y coordinatePoint - new Point with self as x10 @ 20 "=> Point(10, 20)"

Interval

MethodTypeParametersReturnsExample
startPrimitive-Integer - start value(1 to: 10) start "=> 1"
stopPrimitive-Integer - end value(1 to: 10) stop "=> 10"
stepPrimitive-Integer - step value(1 to: 10 by: 2) step "=> 2"
sizePrimitive-Integer - number of elements(1 to: 10) size "=> 10"
asArrayPrimitive-Array - interval as array(1 to: 5) asArray "=> #(1 2 3 4 5)"
includes:Primitivevalue Integer - value to checkBoolean - true if in interval(1 to: 10) includes: 5 "=> true"
by:Primitivestep Integer - new step valueInterval - new interval with step(1 to: 10) by: 2

Interval class

MethodTypeParametersReturnsExample
from:to:Primitivestart Integer - start value, end Integer - end valueInterval - new interval with step 1Interval from: 1 to: 10
from:to:by:Primitivestart Integer - start value, end Integer - end value, step Integer - step valueInterval - new interval with custom stepInterval from: 1 to: 10 by: 2

Json class

MethodTypeParametersReturnsExample
parse:Primitivestring String - JSON string to parseAny - parsed value (Dict, Array, String, Integer, Float, Boolean, nil)Json parse: '{"name": "Alice", "age": 30}'
generate:Primitivevalue Any - value to serializeString - JSON stringJson generate: (Dict new at: 'name' put: 'Alice')
generate:options:Primitivevalue Any - value to serialize, options Dict - options (e.g., 'pretty' -> true)String - JSON stringJson generate: data options: (Dict new at: 'pretty' put: true)

OrderedCollection

MethodTypeParametersReturnsExample
sizePrimitive-Integer - number of elementscoll size
add:Primitivevalue Any - value to appendselfcoll add: 42
addFirst:Primitivevalue Any - value to prependselfcoll addFirst: 1
removeFirstPrimitive-Any - removed first elementcoll removeFirst
removeLastPrimitive-Any - removed last elementcoll removeLast
remove:Primitivevalue Any - value to removeAny - removed value, or nil if not foundcoll remove: 42
at:Primitiveindex Integer - 1-based indexAny - element at indexcoll at: 1
includes:Primitivevalue Any - value to search forBoolean - true if foundcoll includes: 42
firstPrimitive-Any - first elementcoll first
lastPrimitive-Any - last elementcoll last
asArrayPrimitive-Array - elements as arraycoll asArray
copyFrom:to:Primitivestart Integer - 1-based start index, end Integer - 1-based end index (inclusive)OrderedCollection - new sliced collectioncoll copyFrom: 2 to: 4

OrderedCollection class

MethodTypeParametersReturnsExample
newPrimitive-OrderedCollection - new empty collectionOrderedCollection new

Path class

MethodTypeParametersReturnsExample
basename:Primitivepath String - file pathString - file name without directoryPath basename: '/home/user/file.txt' "=> 'file.txt'"
dirname:Primitivepath String - file pathString - directory part of pathPath dirname: '/home/user/file.txt' "=> '/home/user'"
extension:Primitivepath String - file pathString - file extension (without dot)Path extension: 'file.txt' "=> 'txt'"
join:with:Primitivebase String - base path, child String - child pathString - joined pathPath join: '/home' with: 'user' "=> '/home/user'"
absolute:Primitivepath String - relative pathString - absolute pathPath absolute: 'file.txt'
exists:Primitivepath String - path to checkBoolean - true if path existsPath exists: '/tmp'
isDirectory:Primitivepath String - path to checkBoolean - true if path is a directoryPath isDirectory: '/tmp'

Point

MethodTypeParametersReturnsExample
xPrimitive-Number - x coordinate(10 @ 20) x "=> 10"
yPrimitive-Number - y coordinate(10 @ 20) y "=> 20"
x:Primitivevalue Number - new x coordinateselfpoint x: 30
y:Primitivevalue Number - new y coordinateselfpoint y: 40

Process class

MethodTypeParametersReturnsExample
run:args:Primitivecommand String - command to run, args Array - array of argumentsInteger - exit codeProcess run: 'ls' args: #('-la')
output:args:Primitivecommand String - command to run, args Array - array of argumentsString - captured stdout outputProcess output: 'echo' args: #('hello')

Random class

MethodTypeParametersReturnsExample
nextPrimitive-Float - random float between 0.0 and 1.0Random next
nextInt:Primitivemax Integer - exclusive upper boundInteger - random integer from 0 to max-1Random nextInt: 100

Set

MethodTypeParametersReturnsExample
add:Primitivevalue Any - value to addselfset add: 42
includes:Primitivevalue Any - value to checkBoolean - true if memberset includes: 42
sizePrimitive-Integer - number of elementsset size
remove:Primitivevalue Any - value to removeAny - removed value, or nilset remove: 42
union:Primitiveother Set - set to union withSet - new set with all elementsset1 union: set2
intersection:Primitiveother Set - set to intersect withSet - new set with common elementsset1 intersection: set2
difference:Primitiveother Set - set to subtractSet - new set with elements not in otherset1 difference: set2
asArrayPrimitive-Array - elements as arrayset asArray

Set class

MethodTypeParametersReturnsExample
newPrimitive-Set - new empty setSet new

Sha2 class

MethodTypeParametersReturnsExample
hash256:Primitivedata String - data to hashString - SHA-256 hash as hex stringSha2 hash256: 'hello'
sha256:Primitivedata String - data to hash (alias for hash256:)String - SHA-256 hash as hex stringSha2 sha256: 'hello'
hash512:Primitivedata String - data to hashString - SHA-512 hash as hex stringSha2 hash512: 'hello'
sha512:Primitivedata String - data to hash (alias for hash512:)String - SHA-512 hash as hex stringSha2 sha512: 'hello'

Sqlite

MethodTypeParametersReturnsExample
execute:Primitivesql String - SQL statement to executeBoolean - true on successdb execute: 'CREATE TABLE users (id INTEGER, name TEXT)'
execute:with:Primitivesql String - SQL statement with ? placeholders, params Array - parameter valuesBoolean - true on successdb execute: 'INSERT INTO users VALUES (?, ?)' with: #(1 'Alice')
query:Primitivesql String - SELECT statementArray - array of Dict rows, or nil on errordb query: 'SELECT * FROM users'
query:with:Primitivesql String - SELECT statement with ? placeholders, params Array - parameter valuesArray - array of Dict rows, or nil on errordb query: 'SELECT * FROM users WHERE id = ?' with: #(1)
queryScalar:Primitivesql String - SELECT returning single valueAny - scalar value, or nil on errordb queryScalar: 'SELECT COUNT(*) FROM users'
queryScalar:with:Primitivesql String - SELECT with ? placeholders returning single value, params Array - parameter valuesAny - scalar value, or nil on errordb queryScalar: 'SELECT name FROM users WHERE id = ?' with: #(1)

Sqlite class

MethodTypeParametersReturnsExample
open:Primitivepath String - database file path (':memory:' for in-memory DB)Sqlite - database connection, or nil on errorSqlite open: 'mydb.sqlite'
openWith:Primitivepath String - database file path (alias for open:)Sqlite - database connection, or nil on errorSqlite openWith: ':memory:'

Stdin class

MethodTypeParametersReturnsExample
readLinePrimitive-String - one line from standard inputStdin readLine
readAllPrimitive-String - all remaining input from stdinStdin readAll

String

MethodTypeParametersReturnsExample
sizePrimitive-Integer - number of characters'hello' size "=> 5"
at:Primitiveindex Integer - 1-based indexCharacter - character at index'hello' at: 2 "=> $e"
,Primitiveother String - string to appendString - concatenated string'hello' , ' world' "=> 'hello world'"
split:Primitivedelimiter String - delimiter to split onArray - array of substrings'a,b,c' split: ',' "=> #('a' 'b' 'c')"
trimPrimitive-String - string with leading/trailing whitespace removed' hello ' trim "=> 'hello'"
asUppercasePrimitive-String - uppercase version'hello' asUppercase "=> 'HELLO'"
asLowercasePrimitive-String - lowercase version'HELLO' asLowercase "=> 'hello'"
includes:Primitivesubstring String - substring to search forBoolean - true if contains substring'hello' includes: 'ell' "=> true"
beginsWith:Primitiveprefix String - prefix to checkBoolean - true if starts with prefix'hello' beginsWith: 'he' "=> true"
endsWith:Primitivesuffix String - suffix to checkBoolean - true if ends with suffix'hello' endsWith: 'lo' "=> true"
copyFrom:to:Primitivestart Integer - 1-based start index, end Integer - 1-based end index (inclusive)String - substring'hello' copyFrom: 2 to: 4 "=> 'ell'"
replace:with:Primitiveold String - substring to replace (first occurrence), new String - replacement stringString - new string with replacement'hello' replace: 'l' with: 'L' "=> 'heLlo'"
replaceAll:with:Primitiveold String - substring to replace (all occurrences), new String - replacement stringString - new string with all replacements'hello' replaceAll: 'l' with: 'L' "=> 'heLLo'"
*Primitivecount Integer - number of repetitionsString - repeated string'ab' * 3 "=> 'ababab'"
match:Primitivepattern String - regex patternBoolean - true if matches'hello' match: 'h.*o' "=> true"
matchGroups:Primitivepattern String - regex pattern with capture groupsArray - array of captured groups, or nil if no match'hello123' matchGroups: '([a-z]+)([0-9]+)' "=> #('hello123' 'hello' '123')"
extract:Primitivepattern String - regex patternArray - all matches as array of strings'a1b2c3' extract: '[0-9]+' "=> #('1' '2' '3')"
asIntegerPrimitive-Integer - parsed integer value'42' asInteger "=> 42"
asNumberPrimitive-Number - parsed float value'3.14' asNumber "=> 3.14"
asStringPrimitive-String - self'hello' asString "=> 'hello'"
displayWidthPrimitive-Integer - display width (handles CJK characters)'hello' displayWidth "=> 5"
findString:startingAt:Primitivesubstring String - substring to find, start Integer - 1-based start positionInteger - 1-based index, or 0 if not found'hello' findString: 'l' startingAt: 1 "=> 3"
indexOf:Primitivesubstring String - substring to findInteger - 1-based index, or 0 if not found'hello' indexOf: 'l' "=> 3"
regexEscapePrimitive-String - string with regex metacharacters escaped'a.b*c' regexEscape "=> 'a\\.b\\*c'"

StringStream

MethodTypeParametersReturnsExample
nextPutAll:Primitivestring String - string to appendselfstream nextPutAll: 'Hello'
contentsPrimitive-String - accumulated string contentsstream contents
sizePrimitive-Integer - current length of contentsstream size
resetPrimitive-self - clears the bufferstream reset
nextPut:Primitivechar Character - character to appendselfstream nextPut: $A

StringStream class

MethodTypeParametersReturnsExample
newPrimitive-StringStream - new empty string streamStringStream new
new:PrimitiveinitialCapacity Integer - initial buffer capacityStringStream - new string stream with capacityStringStream new: 1024

System class

MethodTypeParametersReturnsExample
argsPrimitive-Array - command line argumentsSystem args
heapSizePrimitive-Integer - current heap size in bytesSystem heapSize
platformPrimitive-String - platform name ('windows', 'linux', 'macos')System platform
exit:Primitivecode Integer - exit codenever returns (process exits)System exit: 0
nilTolerantEnterPrimitive-nil - enters nil-tolerant mode (nil message sends return nil)System nilTolerantEnter
nilTolerantLeavePrimitive-nil - leaves nil-tolerant modeSystem nilTolerantLeave
isNilTolerantPrimitive-Boolean - true if in nil-tolerant modeSystem isNilTolerant
performGCPrimitive-nil - triggers garbage collectionSystem performGC
gcPrimitive-nil - alias for performGCSystem gc
gcThresholdPrimitive-Integer - current GC threshold in bytesSystem gcThreshold
gcThreshold:Primitivebytes Integer - new GC threshold in bytesnilSystem gcThreshold: 1000000
onInterrupt:Primitiveblock Block - handler to call on SIGINT (Ctrl+C)nilSystem onInterrupt: [ 'Interrupted!' printNl. System exit: 1 ]
clearInterruptHandlerPrimitive-nil - removes the interrupt handlerSystem clearInterruptHandler
classNamed:Primitivename String - class name to look upClass|nil - the class object, or nil if not foundSystem classNamed: 'String'
allClassesPrimitive-Array - array of all class namesSystem allClasses

Tcp class

MethodTypeParametersReturnsExample
connect:port:Primitivehost String - hostname or IP address, port Integer - port numberTcpStream - connection, or nil on errorTcp connect: 'localhost' port: 8080
connect:port:timeout:Primitivehost String - hostname or IP address, port Integer - port number, timeout Integer - timeout in millisecondsTcpStream - connection, or nil on timeout/errorTcp connect: 'localhost' port: 8080 timeout: 5000

TcpListener

MethodTypeParametersReturnsExample
acceptPrimitive-TcpStream - accepted connection (blocking), or nil on errorlistener accept
closePrimitive-Boolean - true (listener closes on drop)listener close

TcpListener class

MethodTypeParametersReturnsExample
listen:Primitiveport Integer - port to listen on (binds to 0.0.0.0)TcpListener - listener, or nil on errorTcpListener listen: 8080
listenOn:port:Primitiveaddress String - address to bind (e.g., '127.0.0.1'), port Integer - port to listen onTcpListener - listener, or nil on errorTcpListener listenOn: '127.0.0.1' port: 8080

TcpStream

MethodTypeParametersReturnsExample
send:Primitivedata String|ByteArray - data to sendInteger - bytes sent, or nil on errorstream send: 'GET / HTTP/1.0\r\n\r\n'
recv:PrimitivemaxBytes Integer - maximum bytes to receiveByteArray - received data, or nil on error/closedstream recv: 4096
recvPrimitive-ByteArray - received data (default 4096 bytes max), or nilstream recv
recvLinePrimitive-String - line without newline, or nil on error/closedstream recvLine
closePrimitive-Boolean - true on successstream close

Time class

MethodTypeParametersReturnsExample
millisecondClockPrimitive-Integer - milliseconds since VM startup (monotonic)Time millisecondClock
nanosecondClockPrimitive-Integer - nanoseconds since VM startup (monotonic)Time nanosecondClock

Toml class

MethodTypeParametersReturnsExample
parse:Primitivestring String - TOML string to parseDict - parsed TOML as dictionaryToml parse: '[section]\nkey = "value"'

Yaml class

MethodTypeParametersReturnsExample
parse:Primitivestring String - YAML string to parseAny - parsed valueYaml parse: 'name: Alice\nage: 30'

Standard Library

Classes defined in lib/*.st.

Ansi class

MethodTypeParametersReturnsExample
escSmalltalk-String - ESC characterAnsi esc
csiSmalltalk-String - CSI sequence (ESC[)Ansi csi
resetSmalltalk-String - ANSI reset sequenceAnsi reset
wrap: aString with: codeSmalltalkaString String - text to wrap, code String - ANSI codeString - wrapped with ANSI escapeAnsi wrap: 'hello' with: '31'

Array

MethodTypeParametersReturnsExample
productSmalltalk-Number - product of all elements#(1 2 3 4) product => 24
firstSmalltalk-Object - first element#(a b c) first
lastSmalltalk-Object - last element#(a b c) last
allButFirstSmalltalk-Array - all elements except first#(1 2 3) allButFirst
allButLastSmalltalk-Array - all elements except last#(1 2 3) allButLast
take: countSmalltalkcount Integer - number of elements to takeArray - first count elements#(1 2 3 4 5) take: 3
drop: countSmalltalkcount Integer - number of elements to skipArray - remaining elements after skip#(1 2 3 4 5) drop: 2
copySmalltalk-Array - shallow copy#(1 2 3) copy
copyWith: elementSmalltalkelement Object - element to appendArray - new array with element at end#(1 2) copyWith: 3
copyWithout: elementSmalltalkelement Object - element to removeArray - new array without element#(1 2 3 2) copyWithout: 2
indexOf: elementSmalltalkelement Object - element to findInteger - 1-based index or 0 if not found#(a b c) indexOf: b
flattenSmalltalk-Array - flattened by one level#((1 2) (3 4)) flatten
uniqueSmalltalk-Array - with duplicates removed#(1 2 1 3 2) unique
reversedSmalltalk-Array - elements in reverse order#(1 2 3) reversed
zip: otherSmalltalkother Array - array to zip withArray - array of pairs#(1 2 3) zip: #(a b c)
sortSmalltalk-Array - sorted in ascending order#(3 1 4 1 5) sort
sortBy: aBlockSmalltalkaBlock Block - comparator [:a :b | a < b]Array - sorted by comparator#(3 1 4) sortBy: [:a :b | a > b]

Array class

MethodTypeParametersReturnsExample
withAll: aCollectionSmalltalkaCollection Collection - source collectionArray - new array with all elementsArray withAll: (1 to: 5)
with: anObjectSmalltalkanObject Object - the elementArray - single-element arrayArray with: 42
with: first with: secondSmalltalkfirst Object - first element, second Object - second elementArray - two-element arrayArray with: 1 with: 2

CLI.ArgParser

MethodTypeParametersReturnsExample
name: aNameSmalltalkaName String - program nameArgParser - self for chainingparser name: 'my-tool'
description: descSmalltalkdesc String - program descriptionArgParser - self for chainingparser description: 'A useful tool'
flag: longName short: shortName description: descSmalltalklongName String - long flag name, shortName String - short flag name, desc String - descriptionArgParser - self for chainingparser flag: 'verbose' short: 'v' description: 'Verbose'
option: longName short: shortName description: descSmalltalklongName String - long option name, shortName String - short option name, desc String - descriptionArgParser - self for chainingparser option: 'output' short: 'o' description: 'Output file'
positional: aName description: descSmalltalkaName String - positional arg name, desc String - descriptionArgParser - self for chainingparser positional: 'input' description: 'Input file'
parse: argsSmalltalkargs Array - command line argumentsParseResult - parsed resultparser parse: System args

CLI.ParseResult

MethodTypeParametersReturnsExample
isSuccessSmalltalk-Boolean - true if parse succeededresult isSuccess
flag: nameSmalltalkname String - flag nameBoolean - true if flag was setresult flag: 'verbose'
option: nameSmalltalkname String - option nameString - option value or nilresult option: 'output'
positional: nameSmalltalkname String - positional arg nameString - positional value or nilresult positional: 'input'
extrasSmalltalk-Array - extra positional argumentsresult extras

Collection

MethodTypeParametersReturnsExample
isEmptySmalltalk-Boolean - true if collection has no elements#() isEmpty
notEmptySmalltalk-Boolean - true if collection has at least one element#(1 2 3) notEmpty
secondSmalltalk-Object - the second element#(a b c) second
thirdSmalltalk-Object - the third element#(a b c) third
do: aBlockSmalltalkaBlock Block - block to evaluate for each elementnil#(1 2 3) do: [:x | x printNl]
collect: aBlockSmalltalkaBlock Block - transformation blockCollection - new collection with transformed elements#(1 2 3) collect: [:x | x * 2]
select: aBlockSmalltalkaBlock Block - predicate blockCollection - elements where block returns true#(1 2 3 4) select: [:x | x > 2]
reject: aBlockSmalltalkaBlock Block - predicate blockCollection - elements where block returns false#(1 2 3 4) reject: [:x | x > 2]
detect: aBlockSmalltalkaBlock Block - predicate blockObject - first matching element or nil#(1 2 3 4) detect: [:x | x > 2]
detect: aBlock ifNone: exceptionBlockSmalltalkaBlock Block - predicate block, exceptionBlock Block - block to evaluate if not foundObject - first match or exceptionBlock result#(1 2 3) detect: [:x | x > 5] ifNone: [0]
inject: initialValue into: aBlockSmalltalkinitialValue 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: aBlockSmalltalkaBlock Block - two-arg block [:elem :index | ...]nil#(a b c) doWithIndex: [:e :i | (i,e) printNl]
ifEmpty: aBlockSmalltalkaBlock Block - block to evaluate if emptyObject - block result or self#() ifEmpty: ['none']
ifNotEmpty: aBlockSmalltalkaBlock Block - block to evaluate with selfObject - block result or self#(1 2) ifNotEmpty: [:c | c size]
count: aBlockSmalltalkaBlock Block - predicate blockInteger - count of matches#(1 2 3 4) count: [:x | x > 2]
includes: anObjectSmalltalkanObject Object - object to findBoolean - true if found#(1 2 3) includes: 2
join: separatorSmalltalkseparator String - separator between elementsString - joined elements#(1 2 3) join: ', '
anySatisfy: aBlockSmalltalkaBlock Block - predicate blockBoolean - true if any match#(1 2 3) anySatisfy: [:x | x > 2]
allSatisfy: aBlockSmalltalkaBlock Block - predicate blockBoolean - true if all match#(2 4 6) allSatisfy: [:x | x even]
noneSatisfy: aBlockSmalltalkaBlock Block - predicate blockBoolean - true if none match#(1 3 5) noneSatisfy: [:x | x even]
groupBy: keyBlockSmalltalkkeyBlock Block - block to compute keyDictionary - grouped elements#(1 2 3 4) groupBy: [:x | x even]
tallySmalltalk-Dictionary - element occurrence counts#(a b a c) tally

Collection class

MethodTypeParametersReturnsExample
withAll: aCollectionSmalltalkaCollection Collection - source collectionCollection - new collection with all elementsOrderedCollection withAll: #(1 2 3)

Core.Association class

MethodTypeParametersReturnsExample
key: aKey value: aValueSmalltalkaKey Object - the key, aValue Object - the valueAssociation - key-value pairAssociation key: 'name' value: 'John'

Core.Block

MethodTypeParametersReturnsExample
timeToRunSmalltalk-Integer - milliseconds taken to execute the block[ 1000 timesRepeat: [ 1 + 1 ] ] timeToRun

Core.Exception class

MethodTypeParametersReturnsExample
signal: aStringSmalltalkaString String - exception message- raises exceptionException signal: 'Error occurred'

Core.Object

MethodTypeParametersReturnsExample
error: aStringSmalltalkaString String - error message- raises Error exceptionself error: 'Something went wrong'
-> anObjectSmalltalkanObject Object - the valueAssociation - self as key, anObject as value'name' -> 'John'

Core.Object class

MethodTypeParametersReturnsExample
basicNewSmalltalk-Object - uninitialized instancePoint basicNew
newSmalltalk-Object - new initialized instancePoint new

Core.Path class

MethodTypeParametersReturnsExample
stem: aPathSmalltalkaPath String - file pathString - filename without extensionPath stem: 'foo/bar.txt'

Core.String

MethodTypeParametersReturnsExample
stripAnsiSmalltalk-String - with ANSI escape sequences removed'hello' red stripAnsi
displayWidthSmalltalk-Integer - display width accounting for full-width chars'hello' displayWidth
splitOn: aDelimiterSmalltalkaDelimiter String - delimiter to split onArray - array of substrings'a,b,c' splitOn: ','

Core.String class

MethodTypeParametersReturnsExample
join: aCollection with: aDelimiterSmalltalkaCollection Collection - elements to join, aDelimiter String - separator between elementsString - joined stringString join: #(a b c) with: ', '

Core.Time class

MethodTypeParametersReturnsExample
millisecondsToRun: aBlockSmalltalkaBlock Block - block to measureInteger - milliseconds taken to execute the blockTime millisecondsToRun: [ 1000 timesRepeat: [ 1 + 1 ] ]

Dictionary

MethodTypeParametersReturnsExample
do: aBlockSmalltalkaBlock Block - block for each valuenildict do: [:v | v printNl]
keysAndValuesDo: aBlockSmalltalkaBlock Block - two-arg block [:key :value | ...]nildict keysAndValuesDo: [:k :v | k printNl]
hasKey: keySmalltalkkey Object - key to checkBoolean - true if key existsdict hasKey: 'name'
at: key ifAbsent: absentBlockSmalltalkkey Object - key to look up, absentBlock Block - block if key not foundObject - value or block resultdict at: 'x' ifAbsent: [0]
at: key ifAbsentPut: aBlockSmalltalkkey Object - key to look up, aBlock Block - block to compute and store if absentObject - existing or new valuedict at: 'x' ifAbsentPut: [0]

Integer

MethodTypeParametersReturnsExample
evenSmalltalk-Boolean - true if even4 even
oddSmalltalk-Boolean - true if odd5 odd

Maybe class

MethodTypeParametersReturnsExample
value: aBlockSmalltalkaBlock Block - block to execute in nil-tolerant modeObject - block result or nilMaybe value: [dict at: 'key' at: 'sub']

Number

MethodTypeParametersReturnsExample
absSmalltalk-Number - absolute value-5 abs
min: otherSmalltalkother Number - value to compareNumber - smaller value3 min: 5
max: otherSmalltalkother Number - value to compareNumber - larger value3 max: 5

Shell.Sh class

MethodTypeParametersReturnsExample
run: commandStringSmalltalkcommandString String - shell command to executeInteger - exit code (0 = success)Sh run: 'git status'
output: commandStringSmalltalkcommandString String - shell command to executeString - stdout content(Sh output: 'echo hello') printNl
lines: commandStringSmalltalkcommandString String - shell command to executeArray - array of output lines(Sh lines: 'ls') do: [:l | l printNl]
success: commandStringSmalltalkcommandString String - shell command to executeBoolean - true if exit code is 0(Sh success: 'test -f README.md') ifTrue: ['exists' printNl]

String

MethodTypeParametersReturnsExample
redSmalltalk-String - red colored text'error' red
greenSmalltalk-String - green colored text'ok' green
yellowSmalltalk-String - yellow colored text'warning' yellow
blueSmalltalk-String - blue colored text'info' blue
boldSmalltalk-String - bold text'important' bold
underlineSmalltalk-String - underlined text'link' underline
linesSmalltalk-Array - array of lines'a\nb\nc' lines
wordsSmalltalk-Array - array of words split by whitespace'hello world' words
repeat: countSmalltalkcount Integer - number of repetitionsString - repeated string'ab' repeat: 3
isBlankSmalltalk-Boolean - true if empty or whitespace only' ' isBlank
trimLeftSmalltalk-String - with leading whitespace removed' hello' trimLeft
trimRightSmalltalk-String - with trailing whitespace removed'hello ' trimRight
includes: aStringSmalltalkaString String - substring to findBoolean - true if substring exists'hello world' includes: 'wor'
format: collectionSmalltalkcollection Array - values to substituteString - with {1}, {2}, etc replaced'Hello {1}!' format: #('World')

Generated by tools/generate_api_grammar.st