regex: false — programs without regular expressions#
The regex: false capability setting.
Prefix LNRE.
This document is an overlay on the base language and runtime specs.
It does not modify any base spec paragraph; it states how those paragraphs
are interpreted or restricted when regex: false is active. Each overlay
section names the base paragraph it constrains. In particular, regex: false
introduces no mechanism of its own: it reaches the regex dialect form's
existing compile error and the reference engine's existing regex-less
build ([LFCA]) at file granularity.
What regex: false is [LNRE.1]#
Purpose [LNRE.1.1]#
regex: false is the setting of the regex capability ([LFCA.13.1],
[LCAP.2.8]) that forbids the whole regular-expression surface — ~,
!~ and regex literals — in a program and its
libraries. Its purpose: a conforming runtime built for such programs may
omit an RE2-class regex engine entirely ([IRET.23.7]). A program sets it
in its use block, or through a dialect that sets it.
RE2 is a substantial, statically-linked matching engine; a build that
never evaluates a pattern carries none of its code, tables, or Unicode
data. A program compiled with regex: false trades the ability to write a
regex pattern for the smallest possible runtime image.
Unlike linear_scan: false and logical: false, regex: false changes no runtime
timing: regex evaluation under RE2 is already linear-time and bounded
regardless of pattern ([LREG.9.3]), so there is no T_wcet term to
remove. The payoff is static footprint, not execution cost — see
[LNRE.4.3].
see also: LCAP.2.8, LFCA.13.1, IRET.23.7, LREG.9.3, LNRE.4.3
What the user accepts [LNRE.1.2]#
regex: false is an opt-in constraint. Users who choose it accept:
No regex construct anywhere in the program or the libraries it imports ([LNRE.3.1]).
In return they get the property in [LNRE.4]: a runtime hosting this deployment need not link an RE2-class engine at all.
What regex: false is not [LNRE.1.3]#
Not a performance dial. Regex evaluation under RE2 is already bounded-cost ([LREG.9.3]);
regex: falseremoves no timing term and is not alinear_scan: false-style algorithmic-shape constraint.Not implied by
linear_scan: falseorrealtime.linear_scan: falsebounds a regex match's cost ([LNLS.3.7]) but does not forbid regex;realtimeenforces that same bound automatically ([LNLS.2.3]) but likewise does not forbid regex. Both may combine withregex: false, which forbids it outright.Not required for a regex-free program to run on a regex-less runtime. The load-time check in [LNRE.4.2] follows the artefact's content, not its settings, so a program that never writes a regex loads on such a runtime whatever its
regexsetting. Setting it moves the same guarantee earlier, to compile time, and turns a future regex addition into an immediate compile error instead of a deploy-time surprise.Not a special mechanism. It is one capability setting among the others ([LCAP.1]), refused like any other with
DS_VALIDATE_CAPABILITY_DISABLED; it introduces no error code and no runtime behavior of its own.
see also: LCAP.1, LREG.9.3, LNLS.3.7, LNLS.2.3, LNRE.4.2, LFCA.13.1, IRET.23.7
Extension-capability registration [LNRE.2]#
Name and registration [LNRE.2.1]#
regex is a construct capability of [LCAP.1]. A program has
regex: false through its dialect or a line of its use block
([LDIA.2.1]), resolved per [LDIA.3.3]. default has regex: true
([LDIA.9.2]).
Combination with other extensions [LNRE.2.2]#
regex: false combines with any other setting. Interactions:
With |
Effect |
|---|---|
|
[LNLS.3.7]'s regex |
|
[LNLS.2.3]'s enforcement of a regex |
|
No interaction; orthogonal constraints. |
|
No interaction; orthogonal constraints. |
When to use it [LNRE.2.3]#
Goal |
Setting |
|---|---|
A program that will never need regex, targeting a footprint-constrained runtime |
|
A program that may add regex later, or targets a runtime with no image-size constraint |
|
regex: false is a promise about the program's content, not a
requirement for deployment: a regex-free program runs on a regex-less
runtime either way ([LNRE.1.3]). Set it to get the promise checked at
compile time instead of discovered at load time.
see also: LNRE.1.3
Excluded features and compile errors [LNRE.3]#
When regex: false is active, the following is a compile error. The error
message must identify the specific paragraph violated.
Regex literal anywhere in the program [LNRE.3.1]#
Under regex: false ([LFCA.13.1]), a regex literal (/pattern/flags,
[LREG.5]) anywhere in the program or its libraries — in a pattern
condition, a where clause, or an expression argument — is a compile
error, regardless of whether the pattern is ever reached at runtime:
DS_VALIDATE_CAPABILITY_DISABLED, as for every construct a setting
forbids ([LDIA.3.4.2]).
Rationale: the constraint is on the compiled artifact's content, not
its reachable behavior — a regex literal that is dead code still
requires the compiler to validate it against RE2's grammar ([LREG.8]),
which is exactly the dependency regex: false exists to drop.
ratified — see also: LDIA.3.4.2, LFCA.13.1, LREG.5, LREG.8
Runtime effect — RE2 engine omission [LNRE.4]#
A conforming runtime may omit RE2-class engine support [LNRE.4.1]#
A conforming DS runtime may be built without linking an RE2-class
regex engine, for a target whose dialect never enables the regex
form ([LFCA.13.1], [IRET.23.7]). This is a build-time choice of the
integrator, made once for a deployment target — it is independent of
any single DSC's declared capabilities, in the same way a target's
choice of codegens is independent of any one ruleset.
Such a build must still accept every DSC whose requires does not
list regex, and must refuse to load any DSC whose requires lists it
([LNRE.4.2]). It offers no partial or degraded regex support: regex
is either fully present, at RE2's full semantics ([LREG.8.1]), or
absent entirely.
Rejection follows the content, not the setting [LNRE.4.2]#
A regex-less runtime decides whether it can load a DSC from the
artefact's requires ([RDSC.16.2.8]), which the compiler computes from
what the artefact contains, not from its settings. A DSC whose content
uses regex lists regex there, and a build without an RE2-class engine
refuses it with DS_ERR_DSC_CAPABILITY_ABSENT before decoding any body
([RDSC.16.2.7]). The runtime trusts requires and does not check it
against the content ([RDSC.16.2.8]).
This is what makes the capability's absence safe rather than merely
conventional. A DSC that happens to contain no regex loads on a
regex-less runtime whatever its regex setting; a DSC that does contain
one is refused whatever its setting. regex: false changes only when
the author learns about a mismatch — at compile time instead of at load
time ([LNRE.1.3], [LNRE.2.3]) — never whether the runtime accepts the
artefact.
see also: LNRE.1.3, LNRE.2.3, RDSC.16.2.7, RDSC.16.2.8
Footprint, not timing, is what's saved [LNRE.4.3]#
Omitting an RE2-class engine reduces the compiled runtime image's static size — the matching engine's code, tables, and Unicode data are never linked in. It changes no T_wcet term ([LNRE.1.1]): a regex-less build does not run a regex-carrying DSC faster, it simply cannot run one at all ([LNRE.4.1]).
This is a different kind of payoff from every other registered
capability ([LCAP.1]), each of which trades an authoring constraint for
an allocation or algorithmic-shape guarantee. regex: false trades it for a
build-time property of the runtime artifact instead.
Compile and load errors [LNRE.5]#
Code |
Condition |
Paragraph |
|---|---|---|
|
A regex construct appears anywhere in a program with |
[LNRE.3.1], [LFCA.13.1] |
|
A DSC whose |
[LNRE.4.2], [RDSC.16.2.7] |
Neither is specific to regex. The first is a compile-time check made
only under regex: false. The second is a load-time check a regex-less
runtime always performs, independent of the setting ([LNRE.4.2]).
see also: LFCA.13.1, LNRE.3.1, LNRE.4.2, RDSC.16.2.7
What regex: false does not affect [LNRE.6]#
Every other string operation — interpolation, ordering — is unaffected;
regex: falsereaches only regex literals ([LREG.5]) and their evaluation.A runtime built with an RE2-class engine loads a
regex: falseDSC normally; the capability constrains what the author may write, not what such a runtime accepts.Every other registered capability ([LCAP.1]) combines with
regex: falsefreely ([LNRE.2.2]).