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

문서 검색

명세 6.0

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

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

    라이브러리 · std.typeset

    BreakRule.Forbidden

    Makes the associated penalty unselectable.

    BreakRule.Forbidden()
    수신자
    해당 없음
    최소 인자 수
    0
    최대 인자 수
    0

    Declaration and parameters

    링크

    사용 조건

    기본 포함 · 미정

    Import std.typeset in language mode 5.21.

    The current compiler selects std/typeset.tpz for this language mode. Availability in other released editions and inclusion in each installed distribution are Pending.

    수신자

    매개변수 제약

    Allowed carries an int preference for a selectable penalty. Negative values favor a break and positive values discourage it under the selected cost model. Zero is neutral. Every representable int remains an Allowed value rather than becoming a hard rule at a numeric threshold.

    Forced requires every successful paragraph plan to end a line at that boundary. A plan cannot cross it or omit it to improve cost. If the required line cannot be admitted, planning returns the applicable TypesetError instead of ignoring the constraint.

    Forbidden makes that penalty unselectable. It is not represented by a large Allowed preference. Penalty validation and duplicate-boundary rules determine the treatment of caller-supplied penalties at the same position.

    BreakKind records a category and BreakRule records a planning constraint. Selecting a kind does not turn an Allowed penalty into Forced or Forbidden. The selected cost model interprets the Allowed preference and preserves both hard rules.

    Constructing a rule creates an enum value and has no I/O or mutation. Allowed requires an int payload. An argument of another type is rejected with TPZ5001.

    결과

    효과

    실패

    Result and effects

    링크

    This variant expresses a hard prohibition independently of preference magnitude. The category and selected cost model do not make this penalty selectable.

    Resolved contracts

    링크

    Related entries

    링크

    std.typeset →

    Express preference, mandatory breaks, and forbidden breaks explicitly

    링크
    규칙topaz.stdlib.contract.typeset-break-rules.rule

    Express preference, mandatory breaks, and forbidden breaks explicitly

    Allowed carries an int preference for a selectable penalty. Negative values favor a break and positive values discourage it under the selected cost model. Zero is neutral. Every representable int remains an Allowed value rather than becoming a hard rule at a numeric threshold.

    Forced requires every successful paragraph plan to end a line at that boundary. A plan cannot cross it or omit it to improve cost. If the required line cannot be admitted, planning returns the applicable TypesetError instead of ignoring the constraint.

    Forbidden makes that penalty unselectable. It is not represented by a large Allowed preference. Penalty validation and duplicate-boundary rules determine the treatment of caller-supplied penalties at the same position.

    BreakKind records a category and BreakRule records a planning constraint. Selecting a kind does not turn an Allowed penalty into Forced or Forbidden. The selected cost model interprets the Allowed preference and preserves both hard rules.

    Constructing a rule creates an enum value and has no I/O or mutation. Allowed requires an int payload. An argument of another type is rejected with TPZ5001.

    이유

    An explicit variant makes a hard constraint independent of scoring scale. Callers can change the cost model without changing the meaning of a mandatory or forbidden break. Signed preferences remain a separate choice about plan quality.

    Keep signed penalty preferences distinct from hard break rules

    링크
    main.tpzKeep signed penalty preferences distinct from hard break rules플레이그라운드 열기 →
    1. import std.typeset as ts
    2. import std.io
    3. import std.test
    4. let rules = [ts.BreakRule.Allowed(-10000), ts.BreakRule.Allowed(0), ts.BreakRule.Allowed(10000)]
    5. for rule in (rules) {
    6. match (rule) {
    7. case Allowed(value) => io.writeLine("{value}")
    8. case _ => io.writeLine("unexpected rule")
    9. }
    10. }
    기대 출력종료 코드 0
    -10000
    0
    10000
    
    $ topaz run main.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

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

    기대 표준 출력
    1. -10000
    2. 0
    3. 10000

    Reject a noninteger break preference

    링크
    main.tpzReject a noninteger break preference플레이그라운드 열기 →
    1. import std.typeset as ts
    2. let rule = ts.BreakRule.Allowed("avoid")
    기대 출력0이 아닌 종료 코드
    표준 출력 없음.
    $ topaz check main.tpz --format json · 대상 제품 5.21.3
    기대 결과

    기대 결과

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

    • TPZ5001 →

      stdlib-break-rule-requires-integer at main.tpz:2:33

    Diagnostics

    링크

    TPZ5001 →

    메뉴

    다운로드 →