← board

Declaration pre-scan — whole-section symbol visibility (kill declare-before-use)

Problem

PXX resolves identifiers in a single forward pass, so a routine/type/const must be declared before use. FPC (and Delphi) give whole-section visibility: in a unit's implementation, or a program body, any routine may call any other regardless of source order, and mutual recursion needs no manual forward.

Concretely: a helper near the top of parser.inc that calls LowerCase (defined ~6000 lines later in the same compilation) compiles under the FPC seed (whole-unit resolution) but fails self-host with error: undefined variable (LowerCase). We currently dodge this by hand — ordering callees before callers and sprinkling forward — which is fragile and a standing FPC-source-compat gap.

Why pre-scan, not lazy-linking

Two ways to get order-independence:

Scope

Non-goals

Payoff

Acceptance

Landmines

Log