Renderingen-US

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#

io

Examples#

radix/corpus/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` — reads one line from the active input stream
#   • the `↦ regex` conversion — compiling a string pattern into a regex value
#
# Common mistakes:
#   • Not checking is null 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
#
# const _ pattern ← "\d+" ↦ regex   -- compiled regex from string
# const _ input ← read                  -- stdin line read
#
# GRAMMAR:
#   conversion :← stringLit '↦' 'regex'
#   readExpr :← 'read'
#
# EXPECTED OUTPUT:
#   Regex pattern diagnostic, then one stdin line (no .expected — interactive).
#
# BACKEND: Rust/Go/roundtrip e2e whitelist — read not yet lowered for Rust/Go
# (whitelist: read/lege.fab).

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