본문으로 건너뛰기
토파즈6.0 · 출시 전
다운로드 →

문서 검색

명세 6.0

방향키로 결과를 고르고 Enter를 눌러 여세요.

API 이름, 진단 번호, 규칙 또는 프로젝트 주제를 입력하세요.

    라이브러리

    std.io.writeLine

    Writes a string as a line and returns ().

    writeLine(line: string) -> ()
    수신자
    해당 없음
    최소 인자 수
    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.io.writeLine takes one string argument. On a successful host write, it writes that string followed by a newline to standard output and returns ().

    결과

    std.io.writeLine takes one string argument. On a successful host write, it writes that string followed by a newline to standard output and returns ().

    효과

    std.io.writeLine 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.io.writeLine 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.

    Import std.io and call io.writeLine with one string argument.

    Result and effects

    링크
    규칙topaz.rule.std-io.write-line

    writeLine contract

    std.io.writeLine 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.

    규칙topaz.rule.std-io.write-line.normal-boundaries

    String and newline boundaries

    std.io.writeLine 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

    링크
    규칙topaz.rule.std-io.write-line.host-failure

    Host write failures

    A failed std.io.writeLine 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.io.writeLine 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.

    대응

    Use a working standard output sink. Keep output recovery in the embedding host until structured fault production is available.

    Example

    링크

    Run the first program

    링크
    first-program.tpzRun the first program플레이그라운드 열기 →
    1. import std.io
    2. function greet(name: string) -> string {
    3. return "Hello, {name}!"
    4. }
    5. io.writeLine(greet("Topaz"))
    기록된 출력종료 코드 0
    Hello, Topaz!
    
    $ topaz run first-program.tpz --compiler self · 기록에 사용한 토파즈 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. Hello, Topaz!
    관측한 단언 · 통과 · 5.21.3

    종료 코드 0.

    관측한 표준 출력
    1. Hello, Topaz!

    표준 오류 출력 없음.

    • 통과 · expected 0; observed 0
    • 통과 · stdout matches the authored expectation
    • 통과 · stderr matches the authored expectation
    관측한 단언 · 통과 · 5.21.3

    종료 코드 0.

    관측한 표준 출력
    1. Hello, Topaz!

    표준 오류 출력 없음.

    • 통과 · expected 0; observed 0
    • 통과 · stdout matches the authored expectation
    • 통과 · stderr matches the authored expectation

    Write empty, Unicode, and multiline strings

    링크
    write-line-boundaries.tpzWrite empty, Unicode, and multiline strings플레이그라운드 열기 →
    1. import std.io
    2. io.writeLine("")
    3. io.writeLine("토파즈")
    4. let result: () = io.writeLine("a\nb")
    5. io.writeLine("{result}")
    기대 출력종료 코드 0
    
    토파즈
    a
    b
    ()
    
    $ topaz run write-line-boundaries.tpz --compiler self · 대상 제품 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. 토파즈
    2. a
    3. b
    4. ()

    Reject a non-string argument

    링크
    write-line-bad.tpzReject a non-string argument플레이그라운드 열기 →
    1. import std.io
    2. io.writeLine(1)
    기대 출력0이 아닌 종료 코드
    표준 출력 없음.
    $ topaz check write-line-bad.tpz --compiler self · 대상 제품 5.21.3
    기대 결과

    기대 결과

    거절 단계 check. 종료 코드가 0이 아닙니다.

    • TPZ5001 →

      write-line-string-argument-type at write-line-bad.tpz:2:14

    A successful write has a Unit result

    링크
    write-line-unit-result.tpzA successful write has a Unit result플레이그라운드 열기 →
    1. import std.io
    2. let result: () = io.writeLine("hello")
    기대 출력종료 코드 0
    표준 출력 없음.
    $ topaz check write-line-unit-result.tpz --compiler self --format json · 대상 제품 5.21.3
    기대 결과

    기대 결과

    검사가 프로그램을 받아들입니다. 종료 코드 0.

    A write result cannot use Result propagation

    링크
    write-line-not-result.tpzA write result cannot use Result propagation플레이그라운드 열기 →
    1. import std.io
    2. function greeting() -> Result<(), string> {
    3. io.writeLine("hello")?
    4. Ok(())
    5. }
    기대 출력0이 아닌 종료 코드
    표준 출력 없음.
    $ topaz check write-line-not-result.tpz --compiler self · 대상 제품 5.21.3
    기대 결과

    기대 결과

    거절 단계 check. 종료 코드가 0이 아닙니다.

    • TPZ5001 →

      result-required-for-propagation at write-line-not-result.tpz:4:3

    Related entries

    링크

    First checked and executed program →

    check →

    Functions and generics →

    TPZ5001 →

    메뉴

    다운로드 →