← board

Explicit type-casts (Char/Boolean/String and a general TypeName(expr))

Motivation

Type-casting in PXX is ad-hoc: the factor parser (parser.inc ~2372) has a hardcoded allowlist of cast tokens, not a general TypeName(expr) mechanism. Surveyed 2026-06-18 (surfaced while wiring managed strings on ESP, but target-independent — same char/shortstring/ansistring typing family as the literal-concat fold fix):

Cast Parses Notes
Integer/LongWord/Byte/Word/Cardinal collapse to tkInteger_T, passthrough
Pointer passthrough
Ord / Chr char<->int passthrough builtins
PChar(s) inline-string -> const char* adapter
Char(x) tkChar_T cast not wired -> "expected expression"
Boolean(x) tkBoolean_T not wired
String(x) tkString_T not wired

Not urgent: Boolean and Char are easily worked around today (Ord/Chr, or arithmetic), and String(x) has little use until external-library interop grows (PChar->string already works for imports). Filed so the gap is tracked.

Scope

Acceptance

Notes

Log