spec: What is the definition of a symbol?

Basile B. b2.temp at gmx.com
Fri Nov 20 21:16:47 UTC 2020

On Friday, 20 November 2020 at 19:03:30 UTC, Dibyendu Majumdar 
> The language spec uses the term symbol but I don't think this 
> term is defined anywhere.
> What would be the best way to define it (other than saying it 
> is a symbol in symbol table in the compiler)?

I'd go for something like that:

«A symbol is a declaration. This includes

- variables
- functions
- aggregate types (classes, structures, unions, interfaces)
- aliases
- templates
- enumerations
- modules
- imports

One of the most basic but important task of the compiler is to 
resolve identifiers to symbols. Identifiers as found in 
expressions are never symbols but they always resolve to one. If 
an identifier cannot be resolved to a symbol then compilation 

See also [1].


More information about the Digitalmars-d mailing list