Renderingen-US

Experimental through version 1. Version 0 was alpha. This is the first language release: the interface is relatively stable, not frozen. Nothing is promised stable until version 2.

read

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

Reads input from the active input stream.

Syntax: read [line]

Category#

console

Examples#

radix/corpus/reference/keyword/lege/lege-stdin.fab (canonical · keyword)#

Reads all of stdin to end of input.

# =============================================================================
# lege-stdin — Reads all of stdin to end of input.
# =============================================================================
#
# Q-E5 (ruled 2026-10-15): "read" returns all of stdin to EOF; "read line" one
# line without its terminator. The returned text keeps the input's newlines,
# including the last one.
#
# See also: read, line, write
# =============================================================================

main {
    let _ all ← read
    print all
}

Expected output:

one
two

radix/corpus/reference/keyword/lege/lege.fab (canonical · keyword)#

Reads input from the active input stream.

# =============================================================================
# read — Reads input from the active input stream.
# =============================================================================
#
# What this teaches:
#   • stdin input with `read` — `read` returns all of stdin to end of input,
#     here the one line of the sibling lege.stdin fixture
#   • the `↦ regex` conversion — compiling a string pattern into a regex value
#
# Common mistakes:
#   • Not checking `is none` before using the value — `read` may return `null` at end of input.
#
# See also: line, write
# =============================================================================

# read and regex conversion — I/O read and compiled pattern expressions
#
# let _ pattern ← "\d+" ↦ regex   -- compiled regex from string
# let _ input ← read                  -- stdin line read
#
# GRAMMAR:
#   conversion :← stringLit '↦' 'regex'
#   readExpr :← 'read'
#
# EXPECTED OUTPUT:
#   lege.expected — the compiled regex pattern, then the fixture text. The text
#   keeps its own final newline, so `print` leaves a blank line after it.
#
# BACKEND:
#   Targets read the fixture through the case manifest's `stdin` field; the
#   outcomes row of each target pins how it handles a whole-stream read.

main {
    let regex pattern ← "(?i)\\d+" ↦ regex
    print pattern
    let string ∪ none input ← read
    print input
}

Expected output:

(?i)\d+
salve