IO
IO
The IO module provides process-facing input and output facilities for Scheme programs and embedded services. It includes console output, environment access, files and streams, HTTP helpers, serialization, argument handling, and server-control functions.
IO functions are intentionally effectful. Treat filenames, URLs, environment values, request data, and generated output as trust boundaries; restrict administrative handlers and do not expose arbitrary IO primitives to untrusted users.
Prints values to stdout (only in IO environment)
Allowed number of parameters: 0–10000
Parameters
- value... (
any): values to print (variadic)
Returns
- value (
bool)
env
returns the content of a environment variable
Allowed number of parameters: 1–2
Parameters
- var (
string): envvar - default (
string): default if the env is not found (optional)
Returns
- value (
string)
help
Lists all functions or returns help for a specific function as a string
Allowed number of parameters: 0–1
Parameters
- topic (
string): function to get help about (optional)
Returns
- value (
string)
import
Imports a file .scm file into current namespace
Allowed number of parameters: 1–1
Parameters
- filename (
string): filename relative to folder of source file or absolute path
Returns
- value (
any)
load
Loads a file or stream and returns the string or iterates line-wise
Allowed number of parameters: 1–3
Parameters
- filenameOrStream (
string|stream): filename relative to folder of source file, absolute path, or stream to read from - linehandler (
func): handler that reads each line; each line may end with delimiter (optional)- Parameters
- line (
string)
- line (
- Returns
- value (
any)
- value (
- Parameters
- delimiter (
string): delimiter to extract; if no delimiter is given, the file is read as whole and returned or passed to linehandler (optional)
Returns
- value (
string|bool)
stream
Opens a file readonly as stream
Allowed number of parameters: 1–1
Parameters
- filename (
string): filename relative to folder of source file or absolute path
Returns
- value (
stream)
watch
Loads a file and calls the callback. Whenever the file changes on disk, the file is load again.
Allowed number of parameters: 2–2
Parameters
- filename (
string): filename relative to folder of source file or absolute path - updatehandler (
func): handler that receives the file content whenever it changes- Parameters
- content (
string): new file content
- content (
- Returns
- result (
any): ignored handler result
- result (
- Parameters
Returns
- value (
bool)
serve
Opens a HTTP server at a given port
Allowed number of parameters: 2–2
Parameters
- port (
number): port number for HTTP server - handler (
func): handler that processes each HTTP request- Parameters
- req (
any): HTTP request object - res (
any): HTTP response object
- req (
- Returns
- result (
any): handler result
- result (
- Parameters
Returns
- value (
bool)
serveStatic
creates a static-file HTTP handler for use with serve
Allowed number of parameters: 1–1
Parameters
- directory (
string): folder with the files to serve
Returns
- handler (
func): HTTP handler that serves files from the configured directory- Parameters
- req (
any): HTTP request object - res (
any): HTTP response object
- req (
- Returns
- result (
any): handler result
- result (
- Parameters
mysql
Imports a file .scm file into current namespace
Allowed number of parameters: 4–4
Parameters
- port (
number): port number for MySQL server - getPassword (
func): returns the password for a user, or nil to deny login- Parameters
- username (
string): user attempting to log in
- username (
- Returns
- password (
string|nil): password used for authentication, or nil to deny login
- password (
- Parameters
- schemacallback (
func): checks whether a user may access a schema- Parameters
- username (
string): authenticated user - schema (
string): requested schema
- username (
- Returns
- allowed (
bool): whether access is allowed
- allowed (
- Parameters
- handler (
func): processes one SQL query in a schema- Parameters
- schema (
string) - sql (
string) - resultrow (
func): emits one result row- Parameters
- row (
list<any>)- column value (
any)
- column value (
- row (
- Returns
- result (
any)
- result (
- Parameters
- session (
func): reads or updates request-local values- Parameters
- key (
any) (optional) - value (
any) (optional)
- key (
- Returns
- stored value (
any)
- stored value (
- Parameters
- schema (
- Returns
- value (
any)
- value (
- Parameters
Returns
- value (
bool)
mysql_socket
Listen on a Unix domain socket for MySQL protocol
Allowed number of parameters: 4–4
Parameters
- socketpath (
string): path to the Unix domain socket - getPassword (
func): returns the password for a user, or nil to deny login- Parameters
- username (
string): user attempting to log in
- username (
- Returns
- password (
string|nil): password used for authentication, or nil to deny login
- password (
- Parameters
- schemacallback (
func): checks whether a user may access a schema- Parameters
- username (
string): authenticated user - schema (
string): requested schema
- username (
- Returns
- allowed (
bool): whether access is allowed
- allowed (
- Parameters
- handler (
func): processes one SQL query in a schema- Parameters
- schema (
string) - sql (
string) - resultrow (
func): emits one result row- Parameters
- row (
list<any>)- column value (
any)
- column value (
- row (
- Returns
- result (
any)
- result (
- Parameters
- session (
func): reads or updates request-local values- Parameters
- key (
any) (optional) - value (
any) (optional)
- key (
- Returns
- stored value (
any)
- stored value (
- Parameters
- schema (
- Returns
- value (
any)
- value (
- Parameters
Returns
- value (
bool)
password
Hashes a password with sha1 (for mysql user authentication)
Allowed number of parameters: 1–1
Parameters
- password (
string): plain text password to hash
Returns
- value (
string)
shutdown
Initiates a graceful shutdown of memcp after a short delay
Allowed number of parameters: 0–0
Parameters
This function has no parameters.
Returns
- value (
bool)
crash
Hard process exit with no cleanup (kill -9 equivalent) for crash testing. SCM only, not exposed to SQL.
Allowed number of parameters: 0–0
Parameters
This function has no parameters.
Returns
- value (
bool)
path
Joins path segments using the OS path separator and cleans the result
Allowed number of parameters: 0–10000
Parameters
- segments (
string): path segments to join (variadic)
Returns
- value (
string)
args
Returns command line arguments
Allowed number of parameters: 0–0
Parameters
This function has no parameters.
Returns
- value (
list)
arg
Gets a command line argument value
Allowed number of parameters: 2–3
Parameters
- longname (
string): long argument name (without --) - shortname (
string|any): short argument name (without -) or default value if only 2 args - default (
any): default value if argument not found (optional)
Returns
- value (
any)