digitalmars.D - spec: What is the definition of a symbol?
- Dibyendu Majumdar (4/4) Nov 20 2020 The language spec uses the term symbol but I don't think this
- Max Haughton (3/7) Nov 20 2020 Anything other than an expression?
- H. S. Teoh (5/13) Nov 20 2020 A symbol is not an expression. It may *refer* to an expression, though.
- Paul Backus (3/5) Nov 20 2020 In fact, an expression is one of the few things a symbol *cannot*
- Paul Backus (5/9) Nov 20 2020 A symbol is a name that refers to some entity in the program--a
- Basile B. (20/24) Nov 20 2020 I'd go for something like that:
- Paul Backus (3/5) Nov 20 2020 A symbol is not a declaration. `int x;` is a declaration, but `x`
- Basile B. (4/11) Nov 20 2020 `int x;` is a variable declaration. Variable declarations are all
- Paul Backus (8/15) Nov 20 2020 You're confusing the map for the territory. The fact that
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)?
Nov 20 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)?Anything other than an expression?
Nov 20 2020
On Fri, Nov 20, 2020 at 07:10:41PM +0000, Max Haughton via Digitalmars-d wrote:On Friday, 20 November 2020 at 19:03:30 UTC, Dibyendu Majumdar wrote:A symbol is not an expression. It may *refer* to an expression, though. T -- "Real programmers can write assembly code in any language. :-)" -- Larry WallThe 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)?Anything other than an expression?
Nov 20 2020
On Friday, 20 November 2020 at 19:25:26 UTC, H. S. Teoh wrote:A symbol is not an expression. It may *refer* to an expression, though.In fact, an expression is one of the few things a symbol *cannot* refer to.
Nov 20 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)?A symbol is a name that refers to some entity in the program--a module, a package, a type, a function, a variable, a template, or an `enum` constant. (I think that's the complete list.)
Nov 20 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_
Nov 20 2020
On Friday, 20 November 2020 at 21:16:47 UTC, Basile B. wrote:I'd go for something like that: «A symbol is a declaration. This includesA symbol is not a declaration. `int x;` is a declaration, but `x` by itself is not.
Nov 20 2020
On Friday, 20 November 2020 at 21:23:24 UTC, Paul Backus wrote:On Friday, 20 November 2020 at 21:16:47 UTC, Basile B. wrote:`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.I'd go for something like that: «A symbol is a declaration. This includesA symbol is not a declaration. `int x;` is a declaration, but `x` by itself is not.
Nov 20 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: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.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.
Nov 20 2020