The Rye console is an interactive environment for evaluating Rye code and exploring the language. It provides specialized functions for navigating contexts, discovering available functions, and understanding the structure of your program’s environment.
When you start Rye with the rye
command, you enter the interactive console. A new context is created with the builtin functions available as the parent context.
$ rye
Welcome to Rye console
x> ; your cursor will be here
The Rye environment is organized around contexts - containers for words (variables and functions). You can navigate and explore these contexts using console-specific functions.
Use lc
(list context) to see what’s defined in your current context:
x> lc
Empty context
[Bool: true] ; the returned value
Use lcp
(list context parent) to see the builtin functions available:
x> lcp
Context: Context of builtins
^check: [BFunction(2): Returning Check. (core) (^check)]
^fail: [BFunction(1): Returning Fail. (core) (^fail)]
^fix: [BFunction(2): Fix as a returning function. If Arg 1 is failure, do the block and return to caller. (core) (^fix)]
_+: [Pure BFunction(2): Adds or joins two values together (Integers, Strings, Uri-s and Blocks) (core) (_+)]
_-: [Pure BFunction(2): Subtracts two numbers. (core) (_-)]
_*: [Pure BFunction(2): Multiplies two numbers. (core) (_*)]
...and hundreds more...
Use lc\
with a string to filter functions by name:
x> lc\ "print"
Context: Context of builtins
print: [BFunction(1): Prints a value and adds a newline. (core) (print)]
print\csv: [BFunction(1): Prints CSV formatted output. (core) (print\csv)]
print\json: [BFunction(1): Prints JSON formatted output. (core) (print\json)]
printv: [BFunction(2): Prints a value with custom formatting. (core) (printv)]
Filter by value type using a word:
x> lc\ 'context
Context: Context of builtins
math: [Context: Mathematical functions]
os: [Context: Operating system functions]
pipes: [Context: Pipeline functions]
Use cc
(change context) to move into a specific context:
x> cc math
x> lc
Context: Mathematical context
sin: [BFunction(1): Sine function]
cos: [BFunction(1): Cosine function]
...
Use ccp
(change context to parent) to move up one level:
x> ccp
; Returns the context you're moving from
x> lc
; Now shows the parent context
Rye supports generic functions that dispatch based on the type of their first argument. These are listed separately from regular functions.
Use lg
(list generic) to see generic functions that work with specific types:
x> lg 'table
Context: Generic functions for tables
query: [BFunction: Executes SQL queries on tables]
where-equal: [BFunction: Filters table rows by equality]
add-row: [BFunction: Adds rows to tables]
...
Use lg\
to filter generic functions by both type and name:
x> lg\ 'file "read"
Context: Generic functions for files
read-string: [BFunction: Reads file content as string]
read-lines: [BFunction: Reads file content as lines]
...
Use lg
with a string to find all generic functions related to that concept:
x> lg "http"
Context: Generic functions
query: [BFunction: HTTP query functions for various types]
request: [BFunction: HTTP request functions]
...
The Rye console supports various keyboard shortcuts for efficient editing and navigation:
Press Tab to auto-complete function names, variables, and context words:
x> pri<Tab>
; Expands to available completions:
; print, print\csv, print\json, printv
x> math/<Tab>
; Shows available functions in math context:
; sin, cos, tan, sqrt, ...
Use Ctrl+X to execute multi-line code blocks when the parser detects incomplete input:
x> list {
1 2 3
<incomplete>... 4 5 6
<incomplete>... }<Ctrl+X>
[List: [1 2 3 4 5 6]]
Use lc\data
to get context contents as a data structure instead of printing:
x> words: lc\data
x> words |each { print . }
; Programmatically process all words in context
Create copies of contexts for experimentation:
x> my-ctx: context { x: 100 y: 200 }
x> modified-ctx: clone\ my-ctx { z: x + y }
x> modified-ctx/z
[Integer: 300]
lc\
with search terms to quickly find functions related to your tasklg
to discover generic functions that work with specific data typesenter-console "description"
within your programs to drop into a debugging consoleThe Rye console is designed for exploration and experimentation - don’t hesitate to try functions and inspect the environment to learn how the language works!