Primitive type names such as bool, int32, and string do not need to be lexer keywords. They can instead be ordinary identifiers bound to predefined types in the global type namespace.
With this model:
module Example
struct string {}
struct Value {
local: string // Example::string
primitive: ::string // Global primitive
}
A module can also share a name with a primitive because modules and types occupy different namespaces:
module int32
struct Value {
field: int32 // Global primitive
}
Proposed changes
- Lex primitive names as identifiers rather than dedicated keyword tokens.
- Predefine primitive types in the AST’s global type namespace.
- Resolve primitive and user-defined type references through the same scoped lookup.
- Allow user-defined types to shadow primitives normally.
- Use the requested symbol category during lookup so that modules and types with the same name can coexist.
- Continue accepting escaped spellings such as
\string for compatibility, but make them equivalent to string.
This should remove the primitive grammar production, immediate primitive patching, and dedicated primitive lookup. Result, Sequence, and Dictionary can remain grammar keywords because they introduce constructed-type syntax.
Primitive type names such as
bool,int32, andstringdo not need to be lexer keywords. They can instead be ordinary identifiers bound to predefined types in the global type namespace.With this model:
A module can also share a name with a primitive because modules and types occupy different namespaces:
Proposed changes
\stringfor compatibility, but make them equivalent tostring.This should remove the primitive grammar production, immediate primitive patching, and dedicated primitive lookup.
Result,Sequence, andDictionarycan remain grammar keywords because they introduce constructed-type syntax.