spec: What is the definition of a symbol?

Paul Backus snarwin at gmail.com
Sat Nov 21 00:34:46 UTC 2020

On Saturday, 21 November 2020 at 00:02:15 UTC, Basile B. wrote:
> On Friday, 20 November 2020 at 21:23:24 UTC, Paul Backus wrote:
>> A symbol is not a declaration. `int x;` is a declaration, but 
>> `x` by itself is not.
> `int x;` is a variable declaration. Variable declarations are 
> all symbols (DSymbol in the compiler). `x` in this case 
> represents the symbol name, `int` its type.

You're confusing the map for the territory. The fact that 
`Declaration` is a subclass of `Dsymbol` in the DMD frontend does 
not necessarily mean that a declaration *is* a symbol from the 
perspective of the language spec.

For example, `StaticAssert` is also a subclass of `Dsymbol`, but 
I don't think anyone would seriously argue that `static assert(x 
== y)` is a symbol.

More information about the Digitalmars-d mailing list