read Stdin() - > string- Module
- std.
io - Receiver
- Not applicable
- Minimum arity
- 0
- Maximum arity
- 0
Declaration and parameters
LinkAvailability
Included by default: Pending
Import std.io in language mode 5.21.
The current compiler selects std/io.tpz for this language mode. Availability in other released editions and inclusion in each installed distribution are Pending.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/call_facts.tpz at
b48527d0a174· 285 - compiler/crates/topaz_resolve/src/stdlib.rs at
b48527d0a174· 67 - compiler/crates/topaz_resolve/src/std/521/io.tpz at
b48527d0a174· 4 - compiler/crates/topaz_self_frontend/topaz/checker/call_facts.tpz at
b48527d0a174· 285 - compiler/crates/topaz_self_frontend/topaz/checker/call_facts.tpz at
b48527d0a174· 285 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
b48527d0a174· 1973 - compiler/crates/topaz_self_frontend/topaz/checker/call_facts.tpz at
b48527d0a174· 978 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
b48527d0a174· 1245
Receiver
Parameter constraints
read reads the remaining standard input bytes through EOF. UTF-8 validity and text preservation follow UTF-8 decoding. It does not append or remove a newline.
No remaining bytes produces an empty string. A later call reads from the stream position left by the earlier call and therefore returns an empty string at EOF. A terminal follows the same EOF rule as redirected input.
The call may wait for input or EOF. Reading consumes input even when the result is later discarded. A host read failure or invalid UTF-8 produces a structured runtime fault at the readStdin call because the function returns a string rather than a Result.
The Topaz 6.0 host input fault is TPZ4008. Its primary location is the readStdin call.
Related rule: Read standard input through its endResult
The declared result type is string.
Effects
Failures
Result and effects
LinkConsume the remaining standard input through EOF as strict UTF-8 text. Preserve whitespace and return empty text when no bytes remain.
Related entries
LinkRead standard input through its end
LinkRead standard input through its end
read reads the remaining standard input bytes through EOF. UTF-8 validity and text preservation follow UTF-8 decoding. It does not append or remove a newline.
No remaining bytes produces an empty string. A later call reads from the stream position left by the earlier call and therefore returns an empty string at EOF. A terminal follows the same EOF rule as redirected input.
The call may wait for input or EOF. Reading consumes input even when the result is later discarded. A host read failure or invalid UTF-8 produces a structured runtime fault at the readStdin call because the function returns a string rather than a Result.
The Topaz 6.0 host input fault is TPZ4008. Its primary location is the readStdin call.
Why
Standard input is a stream shared with the host. Consuming it once gives EOF one meaning and lets terminal and redirected input obey the same rule. Strict UTF-8 prevents malformed bytes from silently becoming different text.
Source evidence
- compiler/crates/topaz_resolve/src/std/521/io.tpz at
912a5e86e1f9· 4 - compiler/crates/topaz_self_frontend/topaz/emitter/builtins.tpz at
912a5e86e1f9· 174 - compiler/crates/topaz_host_native/src/lib.rs at
912a5e86e1f9· 311 - compiler/crates/topaz_value/src/value/runtime.rs at
912a5e86e1f9· 448 -
topaz.stdlib.contract.stdin-consumptionatworking-tree - topaz.decision.file-stream-boundaries.1 at
topaz.decisi
Preserve redirected text and its line endings
Linkimport std.iolet text = io.readStdin()io.writeLine(text)
alpha 한글
Expected result
Expected result
Execution completes. Exit code 0.
alpha한글
Source evidence
- compiler/crates/topaz_resolve/src/std/521/io.tpz at
912a5e86e1f9· 4 - compiler/crates/topaz_self_frontend/topaz/emitter/builtins.tpz at
912a5e86e1f9· 174 - compiler/crates/topaz_host_native/src/lib.rs at
912a5e86e1f9· 311 - compiler/crates/topaz_value/src/value/runtime.rs at
912a5e86e1f9· 448 -
topaz.stdlib.contract.stdin-consumptionatworking-tree - topaz.decision.file-stream-boundaries.1 at
topaz.decisi
Return empty text at an empty input stream
Linkimport std.iolet text = io.readStdin()let empty = text == ""io.writeLine("{empty}")
true
Expected result
Expected result
Execution completes. Exit code 0.
true
Source evidence
- compiler/crates/topaz_resolve/src/std/521/io.tpz at
912a5e86e1f9· 4 - compiler/crates/topaz_self_frontend/topaz/emitter/builtins.tpz at
912a5e86e1f9· 174 - compiler/crates/topaz_host_native/src/lib.rs at
912a5e86e1f9· 311 - compiler/crates/topaz_value/src/value/runtime.rs at
912a5e86e1f9· 448 -
topaz.stdlib.contract.stdin-consumptionatworking-tree - topaz.decision.file-stream-boundaries.1 at
topaz.decisi
Observe EOF after standard input has been consumed
Linkimport std.iolet first = io.readStdin()let second = io.readStdin()let atEnd = second == ""io.writeLine(first)io.writeLine("{atEnd}")
alpha true
Expected result
Expected result
Execution completes. Exit code 0.
alphatrue
Source evidence
- compiler/crates/topaz_resolve/src/std/521/io.tpz at
912a5e86e1f9· 4 - compiler/crates/topaz_self_frontend/topaz/emitter/builtins.tpz at
912a5e86e1f9· 174 - compiler/crates/topaz_host_native/src/lib.rs at
912a5e86e1f9· 311 - compiler/crates/topaz_value/src/value/runtime.rs at
912a5e86e1f9· 448 -
topaz.stdlib.contract.stdin-consumptionatworking-tree - topaz.decision.file-stream-boundaries.1 at
topaz.decisi