Break Rule.Forbidden()- Module
- std.
typeset - Receiver
- Not applicable
- Minimum arity
- 0
- Maximum arity
- 0
Declaration and parameters
LinkAvailability
Included by default: Pending
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.
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/model.tpz at
b48527d0a174· 15 - compiler/crates/topaz_resolve/src/stdlib.rs at
b48527d0a174· 40
Receiver
Parameter constraints
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.
Related rule: Express preference, mandatory breaks, and forbidden breaks explicitlyResult
Effects
Failures
Result and effects
LinkThis variant expresses a hard prohibition independently of preference magnitude. The category and selected cost model do not make this penalty selectable.
Resolved contracts
LinkRelated entries
LinkExpress preference, mandatory breaks, and forbidden breaks explicitly
LinkExpress 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.
Why
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.
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/model.tpz at
f3807a34248e· 15-23 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
f3807a34248e· 68-80 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
f3807a34248e· 691-713 - compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
f3807a34248e· 733-755 - compiler/crates/topaz_self_frontend/topaz/checker/call_facts.tpz at
f3807a34248e· 1660-1682 -
topaz.stdlib.contract.typeset-break-rulesatworking-tree
Keep signed penalty preferences distinct from hard break rules
Linkimport 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
Expected result
Expected result
Execution completes. Exit code 0.
-10000010000
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/model.tpz at
f3807a34248e· 15-23 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
f3807a34248e· 68-80 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
f3807a34248e· 691-713 - compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
f3807a34248e· 733-755 - compiler/crates/topaz_self_frontend/topaz/checker/call_facts.tpz at
f3807a34248e· 1660-1682 -
topaz.stdlib.contract.typeset-break-rulesatworking-tree
Reject a noninteger break preference
Linkimport std.typeset as tslet rule = ts.BreakRule.Allowed("avoid")
No stdout.
Expected result
Expected result
Rejection during check. Nonzero exit.
TPZ5001stdlib-break-rule-requires-integer atmain.tpz:2:33
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/model.tpz at
f3807a34248e· 15-23 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
f3807a34248e· 68-80 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
f3807a34248e· 691-713 - compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
f3807a34248e· 733-755 - compiler/crates/topaz_self_frontend/topaz/checker/call_facts.tpz at
f3807a34248e· 1660-1682 -
topaz.stdlib.contract.typeset-break-rulesatworking-tree