In the current compiler, we parse something like "char x[]" or "int" or "Float:" into a temporary object describing the entire type (called a
typeinfo_t). However, all of the existing types have tag equivalences, so this object gets reduced to a single tag and then some information about the array dimensions.
In the v2 mockup compiler, it's a little different. Everything is parsed and resolved into a real type (a
TypeExpr, that holds either a
Type object or a
TypeDescriptor), and there are very specific rules for how types behave. In this model the tag system is almost completely gone, since we can emulate it using types. There is one caveat:
PHP Code:
new Egg:numEggs = Egg:5
Clam numClams;
The first line is valid SourcePawn, since "Egg" is just a tag and tags really don't have any semantic meaning. Tags come into existence simply by using them. The second line, however, is invalid. New-style syntax requires types, and no "Clam" type has been declared.
To preserve this behavior the v2 mockup compiler has to remember which names were used as tags, but never declared as a type. It then creates empty enum types for each of those tags.
EDIT: A final differentiation between tags and types, is that user-created tags have different semantics if they start with a lower-case letter. The coercion rules are relaxed in some circumstances. This won't be preserved in the future.
__________________