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 
wrote:
> 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 
stops.»

See also [1].

[1] 
https://en.wikipedia.org/wiki/Symbol_(programming)#:~:text=A%20symbol%20in%20computer%20programming,languages%2C%20they%20are%20called%20atoms.


More information about the Digitalmars-d mailing list