pub enum Builtin {
Show 151 variants
Car,
Cdr,
Cons,
List,
Null,
Pairp,
Numberp,
Booleanp,
Procedurep,
Symbolp,
EqP,
EqvP,
EqualP,
Add,
Sub,
Mul,
Div,
Modulo,
Remainder,
Quotient,
Expt,
Integerp,
Exactp,
Inexactp,
ExactToInexact,
InexactToExact,
Exact,
Inexact,
Finitep,
Infinitep,
Nanp,
Sqrt,
Floor,
Ceiling,
Truncate,
Round,
Lt,
Gt,
Le,
Ge,
NumEq,
Newline,
Display,
Portp,
InputPortp,
OutputPortp,
CurrentInputPort,
CurrentOutputPort,
CurrentErrorPort,
ClosePort,
CloseInputPort,
CloseOutputPort,
ReadChar,
WriteChar,
PeekChar,
CharReadyp,
Write,
Read,
EofObject,
EofObjectp,
OpenInputString,
OpenOutputString,
GetOutputString,
ReadLine,
ReadString,
WriteShared,
WriteSimple,
TextualPortp,
BinaryPortp,
InputPortOpenp,
OutputPortOpenp,
Error,
ErrorObjectP,
ErrorObjectMessage,
ErrorObjectIrritants,
ErrorObjectType,
SetCar,
SetCdr,
Vectorp,
MakeVector,
Vector,
VectorLength,
VectorRef,
VectorSet,
VectorToList,
ListToVector,
VectorFill,
VectorCopy,
VectorCopyTo,
VectorAppend,
VectorMap,
VectorForEach,
Charp,
CharEq,
CharLt,
CharGt,
CharLe,
CharGe,
CharToInteger,
IntegerToChar,
CharUpcase,
CharDowncase,
Stringp,
MakeString,
String,
StringLength,
StringRef,
StringSet,
StringEq,
StringLt,
StringGt,
StringLe,
StringGe,
StringAppend,
StringToList,
ListToString,
Substring,
StringCopy,
StringCopyTo,
StringFill,
StringCiLt,
StringCiGt,
StringCiLe,
StringCiGe,
Gc,
GcEnable,
GcDisable,
GcEnabledP,
ArenaStats,
Identifierp,
BoundIdentifierEq,
FreeIdentifierEq,
SyntaxToDatum,
SyntaxE,
DatumToSyntax,
DatumToSyntaxObject,
SyntaxObjectToDatum,
GenerateTemporaries,
SymbolToString,
StringToSymbol,
NumberToString,
StringToNumber,
Load,
FileExistsP,
DeleteFile,
CommandLine,
Exit,
EmergencyExit,
GetEnvironmentVariable,
GetEnvironmentVariables,
InteractionEnvironment,
}Expand description
Built-in functions (optimization to avoid symbol lookup)
NOTE: This Lisp supports mutation via set!, set-car!, and set-cdr!
- Mutation operations break referential transparency
- All evaluation is call-by-value (strict)
§Adding New Builtins
To add a new builtin:
- Add an entry to the
define_builtins!macro invocation - Implement its evaluation logic in
grift_eval
Variants§
Car
car - Get first element of pair
Cdr
cdr - Get second element of pair
Cons
cons - Create a pair
List
list - Create a list from arguments
Null
null? - Check if value is the empty list
Pairp
pair? - Check if value is a pair
Numberp
number? - Check if value is a number
Booleanp
boolean? - Check if value is a boolean
Procedurep
procedure? - Check if value is a procedure
Symbolp
symbol? - Check if value is a symbol
EqP
eq? - Scheme-compliant identity equality
EqvP
eqv? - Scheme-compliant value equality
EqualP
equal? - Scheme-compliant recursive structural equality
Add
-
- Addition
Sub
-
- Subtraction
Mul
-
- Multiplication
Div
/ - Division
Modulo
modulo - Scheme modulo (result has sign of divisor)
Remainder
remainder - Scheme remainder (result has sign of dividend)
Quotient
quotient - Integer quotient (truncated towards zero)
Expt
expt - Exponentiation
Integerp
integer? - Check if value is an integer
Exactp
exact? - Check if number is exact (always true for integers)
Inexactp
inexact? - Check if number is inexact (always false for integers)
ExactToInexact
exact->inexact - Convert exact number to inexact
InexactToExact
inexact->exact - Convert inexact number to exact
Exact
exact - R7RS exact conversion
Inexact
inexact - R7RS inexact conversion
Finitep
finite? - Check if number is finite
Infinitep
infinite? - Check if number is infinite
Nanp
nan? - Check if number is NaN
Sqrt
sqrt - Square root
Floor
floor - Largest integer not greater than x (identity for integers)
Ceiling
ceiling - Smallest integer not less than x (identity for integers)
Truncate
truncate - Integer closest to x whose absolute value is not larger (identity for integers)
Round
round - Closest integer to x, rounding to even when x is halfway (identity for integers)
Lt
< - Less than
Gt
- Greater than
Le
<= - Less than or equal
Ge
= - Greater than or equal
NumEq
= - Numeric equality
Newline
newline - Print a newline
Display
display - Print value without quotes
Portp
port? - Check if value is a port
InputPortp
input-port? - Check if value is an input port
OutputPortp
output-port? - Check if value is an output port
CurrentInputPort
current-input-port - Get current input port
CurrentOutputPort
current-output-port - Get current output port
CurrentErrorPort
current-error-port - Get current error port
ClosePort
close-port - Close a port
CloseInputPort
close-input-port - Close an input port
CloseOutputPort
close-output-port - Close an output port
ReadChar
read-char - Read a character from a port
WriteChar
write-char - Write a character to a port
PeekChar
peek-char - Peek at next character without consuming it
CharReadyp
char-ready? - Check if a character is available
Write
write - Write value with machine-readable representation
Read
read - Read an S-expression from a port
EofObject
eof-object - Return the EOF object
EofObjectp
eof-object? - Check if value is the EOF object
OpenInputString
open-input-string - Create an input port from a string
OpenOutputString
open-output-string - Create an output string port
GetOutputString
get-output-string - Get accumulated string from an output string port
ReadLine
read-line - Read a line of text from a port
ReadString
read-string - Read up to k characters from a port
write-shared - Write with shared structure notation
WriteSimple
write-simple - Write without shared structure handling
TextualPortp
textual-port? - Check if port handles text
BinaryPortp
binary-port? - Check if port handles binary data
InputPortOpenp
input-port-open? - Check if input port is still open
OutputPortOpenp
output-port-open? - Check if output port is still open
Error
error - Raise an error
ErrorObjectP
error-object? - Check if value is an error object
ErrorObjectMessage
error-object-message - Get message from error object
ErrorObjectIrritants
error-object-irritants - Get irritants from error object
ErrorObjectType
error-object-type - Get type from error object
SetCar
set-car! - Mutate car of pair
SetCdr
set-cdr! - Mutate cdr of pair
Vectorp
vector? - Check if value is a vector
MakeVector
make-vector - Create a vector with optional fill value
Vector
vector - Create vector from arguments
VectorLength
vector-length - Get length of vector
VectorRef
vector-ref - Get element at index
VectorSet
vector-set! - Set element at index
VectorToList
vector->list - Convert vector to list
ListToVector
list->vector - Convert list to vector
VectorFill
vector-fill! - Fill vector with value
VectorCopy
vector-copy - Copy a vector
VectorCopyTo
vector-copy! - Copy elements from one vector to another
VectorAppend
vector-append - Concatenate vectors
VectorMap
vector-map - Apply procedure to elements of vectors
VectorForEach
vector-for-each - Apply procedure to elements for side effects
Charp
char? - Check if value is a character
CharEq
char=? - Character equality
CharLt
char<? - Character less than
CharGt
char>? - Character greater than
CharLe
char<=? - Character less than or equal
CharGe
char>=? - Character greater than or equal
CharToInteger
char->integer - Convert character to its Unicode code point
IntegerToChar
integer->char - Convert Unicode code point to character
CharUpcase
char-upcase - Convert character to uppercase
CharDowncase
char-downcase - Convert character to lowercase
Stringp
string? - Check if value is a string
MakeString
make-string - Create a string of given length
String
string - Create string from characters
StringLength
string-length - Get length of string
StringRef
string-ref - Get character at index
StringSet
string-set! - Set character at index
StringEq
string=? - String equality
StringLt
string<? - String less than
StringGt
string>? - String greater than
StringLe
string<=? - String less than or equal
StringGe
string>=? - String greater than or equal
StringAppend
string-append - Concatenate strings
StringToList
string->list - Convert string to list of characters
ListToString
list->string - Convert list of characters to string
Substring
substring - Extract a substring
StringCopy
string-copy - Copy a string
StringCopyTo
string-copy! - Copy characters from one string to another
StringFill
string-fill! - Fill string with character
StringCiLt
string-ci<? - Case-insensitive string less than
StringCiGt
string-ci>? - Case-insensitive string greater than
StringCiLe
string-ci<=? - Case-insensitive string less than or equal
StringCiGe
string-ci>=? - Case-insensitive string greater than or equal
Gc
gc - Manually trigger garbage collection
GcEnable
gc-enable - Enable automatic garbage collection
GcDisable
gc-disable - Disable automatic garbage collection
GcEnabledP
gc-enabled? - Check if GC is enabled
ArenaStats
arena-stats - Get arena statistics as a list
Identifierp
identifier? - Check if value is an identifier (symbol or syntax-wrapped symbol)
BoundIdentifierEq
bound-identifier=? - Check if two identifiers have the same name and marks
FreeIdentifierEq
free-identifier=? - Check if two identifiers resolve to the same binding
SyntaxToDatum
syntax->datum - Strip syntax wrapper to get the underlying datum
SyntaxE
syntax-e - Racket-style alias for syntax->datum, extract the datum from a syntax object
DatumToSyntax
datum->syntax - Wrap a datum with syntax context from a template identifier
DatumToSyntaxObject
datum->syntax-object - R6RS alias for datum->syntax
SyntaxObjectToDatum
syntax-object->datum - R6RS alias for syntax->datum
GenerateTemporaries
generate-temporaries - Generate a list of fresh identifiers
SymbolToString
symbol->string - Convert symbol to string
StringToSymbol
string->symbol - Convert string to symbol
NumberToString
number->string - Convert number to string
StringToNumber
string->number - Convert string to number (or #f if invalid)
Load
load - Load and evaluate a Scheme source file
FileExistsP
file-exists? - Check if a file exists
DeleteFile
delete-file - Delete a file
CommandLine
command-line - Return command-line arguments as a list of strings
Exit
exit - Terminate the program normally
EmergencyExit
emergency-exit - Terminate the program immediately without cleanup
GetEnvironmentVariable
get-environment-variable - Get a single environment variable
GetEnvironmentVariables
get-environment-variables - Get all environment variables as an alist
InteractionEnvironment
interaction-environment - Return the mutable REPL environment