Break Rule.Allowed(int)- 수신자
- 해당 없음
- 최소 인자 수
- 1
- 최대 인자 수
- 1
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.
관련 규칙 · Express preference, mandatory breaks, and forbidden breaks explicitly →결과
효과
실패
Result and effects
링크The int payload contributes according to the selected cost model. A negative value favors selection and a positive value discourages it. Numeric magnitudes do not turn this variant into Forced or Forbidden.
Resolved contracts
링크Related entries
링크Express preference, mandatory breaks, and forbidden breaks explicitly
링크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
링크import std.typeset as tsimport std.ioimport std.testlet rules = [ts.BreakRule.Allowed(-10000), ts.BreakRule.Allowed(0), ts.BreakRule.Allowed(10000)]for rule in (rules) {match (rule) {case Allowed(value) => io.writeLine("{value}")case _ => io.writeLine("unexpected rule")}}
-10000
0
10000
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
-10000010000
Reject a noninteger break preference
링크import std.typeset as tslet rule = ts.BreakRule.Allowed("avoid")
표준 출력 없음.