Break Rule.Forced()- Модуль
- std.
typeset → - Получатель
- Неприменимо
- Минимальное число аргументов
- 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.
Связанное правило · Express preference, mandatory breaks, and forbidden breaks explicitly →Результат
Эффекты
Ошибки
Result and effects
СсылкаA plan cannot skip or cross this boundary to improve its score. If the required transition cannot form a valid line, the planner returns the applicable TypesetError.
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")
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
stdlib-break-rule-requires-integer at
main.tpz:2:33