5.2.1 Option Directives
Note
This section describes the implementation of MS-VBAL §5.2.1 Option Directives.
Directives include the Option statements
(RD-VBAL §3.1 Attributes and Directives):
| Directive | Description |
|---|---|
Option Compare |
Determines the comparison mode for string comparisons (§5.2.1.1). |
Option Base |
Determines the base (0 or 1) of implicitly-sized arrays (§5.2.1.2). |
Option Explicit |
Implicit declarations become compile-time errors (§5.2.1.3). |
Option Private Module |
Determines the accessibility of a module (§5.2.1.4). |
A module's LexicalScope carries its ModuleDirectives (RD-VBAL §2.3.1.3 Name Resolution):
| Member | Description |
|---|---|
Explicit |
Whether the module declares Option Explicit. |
Compare |
The module's Option Compare mode. |
Strict |
Reserved for RD-VBA's '@OptionStrict annotation. No symbol provider sets it, so it is always false, and nothing reads it. |
ModuleDirectives is reachable from any scope nested under the module, via
LexicalScope.EnclosingModuleDirectives().
5.2.1.1 Option Compare Directive
Note
This section describes the implementation of MS-VBAL §5.2.1.1 Option Compare Directive.
The Option Compare directive determines the comparison mode for string comparisons: Text or Binary. The
comparison mode may instead be a host-defined token, which dynamically configures the comparison mode.
5.2.1.2 Option Base Directive
Note
This section describes the implementation of MS-VBAL §5.2.1.2 Option Base Directive.
The Option Base directive determines the base (0 or 1) of implicitly-sized arrays.
The lower bound of an uninitialized array value depends on the value of the Option Base directive
(RD-VBAL §2.5.2.1.2 Array Values):
Option Base |
Lower bound |
|---|---|
| Not specified (the default) | 0 |
Option Base 1 |
1 |
Resolving an omitted array lower bound against Option Base is the concern of the semantic pass that materializes
the array value, not of the declaration pass
(RD-VBAL §2.4.1 Intrinsic Types).
5.2.1.3 Option Explicit Directive
Note
This section describes the implementation of MS-VBAL §5.2.1.3 Option Explicit Directive.
Under the Option Explicit directive, implicit declarations become compile-time errors.
Whether the enclosing module declares Option Explicit is the module-level fact a static semantics rule needs
(RD-VBAL §5.0 Semantics, §5.0.1). The static-semantics layer consumes
ModuleDirectives to decide what an unresolved simple name is
(RD-VBAL §5.6.10 Simple Name Expressions):
Module declares Option Explicit |
An unresolved simple name is |
|---|---|
| No | A deferred VBUnknownType. |
| Yes | A VBC09302 Variable not defined compile-time error: an Error carrying VariableNotDefined (VBCompileErrorId). |
An implicit declaration by an unqualified ReDim target is legal under Option Explicit
(RD-VBAL §5.4.3.3 ReDim Statement).
5.2.1.4 Option Private Directive
Note
This section describes the implementation of MS-VBAL §5.2.1.4 Option Private Directive.
The Option Private Module directive determines the accessibility of a module.
⏮️ RD-VBAL §5.2 Module Declaration Section Structure | ⏭️ RD-VBAL §5.2.2 Implicit Definition Directives