write Line(line: string) - > ()- Module
- std.
io - Receiver
- Not applicable
- Minimum arity
- 1
- Maximum arity
- 1
Signature and parameters
LinkAvailability
Included by default: Pending
Import std.io in language mode 5.21.
The selected 5.21 module exports writeLine. Installed default-distribution execution is tracked by the shared check/run fixture.
Source evidence
- compiler/crates/topaz_resolve/src/std/521/io.tpz at
d61f9fd0efb0· 3-5 - compiler/crates/topaz_resolve/src/stdlib.rs at
d61f9fd0efb0· 58-74
Receiver
Parameter constraints
std. takes one string argument. On a successful host write, it writes that string followed by a newline to standard output and returns ().
Result
std. takes one string argument. On a successful host write, it writes that string followed by a newline to standard output and returns ().
Effects
std. takes one string argument. On a successful host write, it writes that string followed by a newline to standard output and returns ().
Failures
A failed std. call raises a dedicated host-output runtime fault at that call.
The Topaz 6.0 fault is TPZ4010. Successful writes retain the normal unit result.
Related rule: Host write failuresImport std.io and call io.writeLine with one string argument.
Result and effects
LinkwriteLine contract
std. takes one string argument. On a successful host write, it writes that string followed by a newline to standard output and returns ().
Why
One string argument keeps value formatting separate from output. Appending a newline makes each successful call complete a line.
Source evidence
- compiler/crates/topaz_resolve/src/std/521/io.tpz at
d61f9fd0efb0· 3-5 - compiler/crates/topaz_resolve/src/stdlib.rs at
d61f9fd0efb0· 58-74 - compiler/crates/topaz_self_frontend/topaz/emitter/builtins.tpz at
d61f9fd0efb0· 32-40 - compiler/crates/topaz_value/src/value/runtime.rs at
d61f9fd0efb0· 634-654 - issues/31 at
570530e69141
String and newline boundaries
std. preserves the supplied string and appends one newline on a successful host write. An empty string writes one newline. Unicode characters and embedded newlines are retained. The function returns (); a non-string argument is a type error. A failed host write produces a structured runtime fault.
Why
Preserving input avoids changing Unicode text or embedded line breaks. One appended newline gives empty and nonempty strings the same output rule.
Source evidence
- writeLine at
151141d7bb44· 3-5 - lispexIntrinsic Print at
151141d7bb44· 30-39 - builtin_print at
151141d7bb44· 634-654 - Host.print at
151141d7bb44· 430-442 - NativeHost.print at
151141d7bb44· 187-190 - reportExpectedType at
151141d7bb44· 1660-1684 - issues/31 at
570530e69141
Failures and boundaries
LinkHost write failures
A failed std. call raises a dedicated host-output runtime fault at that call.
The Topaz 6.0 fault is TPZ4010. Successful writes retain the normal unit result.
Why
Keeping the unit signature preserves the existing call contract. A structured fault makes a host write failure visible to the program runner.
Source evidence
- issues/31 at
570530e69141 - writeLine at
570530e69141· 3-5 - lispexIntrinsic Print at
570530e69141· 30-39 - Host.print at
570530e69141· 430-442 - builtin_print at
570530e69141· 638-654 - NativeHost.print at
570530e69141· 187-190 - codes at
570530e69141· 157-186 - topaz.decision.write-line-host-fault-identity.1 at
topaz.decisi - topaz.decision.host-io-fault-codes.1 at
working-tree
Host output diagnostic
LinkHost output failure
- Family
- topaz
- Phase
- run
- Code
TPZ4010- Operation
- std.io.writeLine
Cause and conditions
A failed std. call raises a dedicated host-output runtime fault at that call.
The Topaz 6.0 fault is TPZ4010. Successful writes retain the normal unit result.
Related rule: Host write failuresResponse
Use a working standard output sink. Keep output recovery in the embedding host until structured fault production is available.
Source evidence
- issues/31 at
570530e69141 - writeLine at
570530e69141· 3-5 - lispexIntrinsic Print at
570530e69141· 30-39 - Host.print at
570530e69141· 430-442 - builtin_print at
570530e69141· 638-654 - NativeHost.print at
570530e69141· 187-190 - codes at
570530e69141· 157-186 - topaz.decision.write-line-host-fault-identity.1 at
topaz.decisi - topaz.decision.host-io-fault-codes.1 at
working-tree
Example
LinkRun the first program
Linkimport std.iofunction greet(name: string) -> string {return "Hello, {name}!"}io.writeLine(greet("Topaz"))
Hello, Topaz!
Expected result
Expected result
Execution completes. Exit code 0.
Hello, Topaz!
Observed assertions · passed · 5.21.3
Exit code 0.
Hello, Topaz!
No stderr.
- Passed · expected 0; observed 0
- Passed · stdout matches the authored expectation
- Passed · stderr matches the authored expectation
Observed assertions · passed · 5.21.3
Exit code 0.
Hello, Topaz!
No stderr.
- Passed · expected 0; observed 0
- Passed · stdout matches the authored expectation
- Passed · stderr matches the authored expectation
Source evidence
- docs/npm/README.md at
d61f9fd0efb0· 48-79 - compiler/crates/topaz_cli/src/command/dispatch.rs at
d61f9fd0efb0· 137-153 - compiler/crates/topaz_resolve/src/std/521/io.tpz at
d61f9fd0efb0· 3-5 - compiler/crates/topaz_self_frontend/topaz/emitter/builtins.tpz at
d61f9fd0efb0· 32-40 - compiler/crates/topaz_value/src/value/runtime.rs at
d61f9fd0efb0· 634-654
Write empty, Unicode, and multiline strings
Linkimport std.ioio.writeLine("")io.writeLine("토파즈")let result: () = io.writeLine("a\nb")io.writeLine("{result}")
토파즈 a b ()
Expected result
Expected result
Execution completes. Exit code 0.
토파즈ab()
Source evidence
- writeLine at
151141d7bb44· 3-5 - lispexIntrinsic Print at
151141d7bb44· 30-39 - builtin_print at
151141d7bb44· 634-654 - Host.print at
151141d7bb44· 430-442 - NativeHost.print at
151141d7bb44· 187-190 - issues/31 at
570530e69141
Reject a non-string argument
Linkimport std.ioio.writeLine(1)
No stdout.
Expected result
Expected result
Rejection during check. Nonzero exit.
TPZ5001write-line-string-argument-type atwrite-line-bad.tpz:2:14
Source evidence
- writeLine at
151141d7bb44· 3-5 - lispexIntrinsic Print at
151141d7bb44· 30-39 - builtin_print at
151141d7bb44· 634-654 - Host.print at
151141d7bb44· 430-442 - NativeHost.print at
151141d7bb44· 187-190 - reportExpectedType at
151141d7bb44· 1660-1684 - issues/31 at
570530e69141
A successful write has a Unit result
Linkimport std.iolet result: () = io.writeLine("hello")
No stdout.
Expected result
Expected result
Checking accepts the program. Exit code 0.
Source evidence
- issues/31 at
570530e69141 - writeLine at
570530e69141· 3-5 - lispexIntrinsic Print at
570530e69141· 30-39 - inferTryExpression at
570530e69141· 1130-1166
A write result cannot use Result propagation
Linkimport std.iofunction greeting() -> Result<(), string> {io.writeLine("hello")?Ok(())}
No stdout.
Expected result
Expected result
Rejection during check. Nonzero exit.
TPZ5001result-required-for-propagation atwrite-line-not-result.tpz:4:3
Source evidence
- issues/31 at
570530e69141 - writeLine at
570530e69141· 3-5 - lispexIntrinsic Print at
570530e69141· 30-39 - inferTryExpression at
570530e69141· 1130-1166