write Line(line: string) - > ()- Модуль
- std.
io → - Получатель
- Неприменимо
- Минимальное число аргументов
- 1
- Максимальное число аргументов
- 1
Signature and parameters
СсылкаДоступность
Включено по умолчанию · Не определено
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.
Получатель
Ограничения параметров
std. takes one string argument. On a successful host write, it writes that string followed by a newline to standard output and returns ().
Результат
std. takes one string argument. On a successful host write, it writes that string followed by a newline to standard output and returns ().
Эффекты
std. takes one string argument. On a successful host write, it writes that string followed by a newline to standard output and returns ().
Ошибки
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.
Связанное правило · Host write failures →Import std.io and call io.writeLine with one string argument.
Result and effects
СсылкаwriteLine contract
std. takes one string argument. On a successful host write, it writes that string followed by a newline to standard output and returns ().
Причина
One string argument keeps value formatting separate from output. Appending a newline makes each successful call complete a line.
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.
Причина
Preserving input avoids changing Unicode text or embedded line breaks. One appended newline gives empty and nonempty strings the same output rule.
Failures and boundaries
СсылкаHost 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.
Причина
Keeping the unit signature preserves the existing call contract. A structured fault makes a host write failure visible to the program runner.
Host output diagnostic
СсылкаHost output failure
- Семейство
- topaz
- Этап
- run
- Код
TPZ4010- Операция
- std.io.writeLine
Причина и условия
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.
Связанное правило · Host write failures →Действия
Use a working standard output sink. Keep output recovery in the embedding host until structured fault production is available.
Example
СсылкаRun the first program
Ссылкаimport std.iofunction greet(name: string) -> string {return "Hello, {name}!"}io.writeLine(greet("Topaz"))
Hello, Topaz!
Ожидаемый результат
Ожидаемый результат
Выполнение завершается. Код завершения 0.
Hello, Topaz!
Наблюдаемые утверждения · Пройдено · 5.21.3
Код завершения 0.
Hello, Topaz!
Нет вывода ошибок.
- Пройдено · expected 0; observed 0
- Пройдено · stdout matches the authored expectation
- Пройдено · stderr matches the authored expectation
Наблюдаемые утверждения · Пройдено · 5.21.3
Код завершения 0.
Hello, Topaz!
Нет вывода ошибок.
- Пройдено · expected 0; observed 0
- Пройдено · stdout matches the authored expectation
- Пройдено · stderr matches the authored expectation
Write empty, Unicode, and multiline strings
Ссылкаimport std.ioio.writeLine("")io.writeLine("토파즈")let result: () = io.writeLine("a\nb")io.writeLine("{result}")
토파즈
a
b
()
Ожидаемый результат
Ожидаемый результат
Выполнение завершается. Код завершения 0.
토파즈ab()
Reject a non-string argument
Ссылкаimport std.ioio.writeLine(1)
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
write-line-string-argument-type at
write-line-bad.tpz:2:14
A successful write has a Unit result
Ссылкаimport std.iolet result: () = io.writeLine("hello")
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Проверка принимает программу. Код завершения 0.
A write result cannot use Result propagation
Ссылкаimport std.iofunction greeting() -> Result<(), string> {io.writeLine("hello")?Ok(())}
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
result-required-for-propagation at
write-line-not-result.tpz:4:3