digitalmars.D.learn - Real beginner traits question
- WhatMeForget (11/11) Sep 24 2017 This is taken exactly from the traits documentation.
- rikki cattermole (15/34) Sep 24 2017 ```D
- H. S. Teoh (8/27) Sep 24 2017 You're not the only one. I stared at this same piece of documentation
- WhatMeWorry (2/11) Sep 25 2017 Thanks. I just created my first enhancement request, issue 17856.
- H. S. Teoh (5/19) Sep 25 2017 https://github.com/dlang/dlang.org/pull/1899
- Jonathan M Davis (13/24) Sep 25 2017 Think of the identifier as the name for the symbol and the symbol as wha...
This is taken exactly from the traits documentation. ------------------------------------------------ 25 Traits 25.21 identifier Takes one argument, a symbol. Returns the identifier for that symbol as a string literal. ------------------------------------------------ There are no examples. My naive brain keeps thinking that a symbol and an identifier are the same things. Can someone give me good definitions of "symbol" and "identifier". And maybe an example if it is not too much trouble.
Sep 24 2017
On 25/09/2017 6:28 AM, WhatMeForget wrote:This is taken exactly from the traits documentation. ------------------------------------------------ 25 Traits 25.21 identifier Takes one argument, a symbol. Returns the identifier for that symbol as a string literal. ------------------------------------------------ There are no examples. My naive brain keeps thinking that a symbol and an identifier are the same things. Can someone give me good definitions of "symbol" and "identifier". And maybe an example if it is not too much trouble.```D void main() {} pragma(msg, __traits(identifier, main)); pragma(msg, __traits(identifier, Foo)); pragma(msg, __traits(identifier, Foo.func)); struct Foo { void func(); } ``` ``` main Foo func ```
Sep 24 2017
On Mon, Sep 25, 2017 at 05:28:13AM +0000, WhatMeForget via Digitalmars-d-learn wrote:This is taken exactly from the traits documentation. ------------------------------------------------ 25 Traits 25.21 identifier Takes one argument, a symbol. Returns the identifier for that symbol as a string literal. ------------------------------------------------ There are no examples. My naive brain keeps thinking that a symbol and an identifier are the same things. Can someone give me good definitions of "symbol" and "identifier". And maybe an example if it is not too much trouble.You're not the only one. I stared at this same piece of documentation for a long time before I figured out what it meant. This is another example of poor documentation writing. Please file a bug, and I'll see if I can get around to making an example for it. T -- Notwithstanding the eloquent discontent that you have just respectfully expressed at length against my verbal capabilities, I am afraid that I must unfortunately bring it to your attention that I am, in fact, NOT verbose.
Sep 24 2017
On Monday, 25 September 2017 at 06:07:58 UTC, H. S. Teoh wrote:On Mon, Sep 25, 2017 at 05:28:13AM +0000, WhatMeForget via Digitalmars-d-learn wrote:Thanks. I just created my first enhancement request, issue 17856.[...]You're not the only one. I stared at this same piece of documentation for a long time before I figured out what it meant. This is another example of poor documentation writing. Please file a bug, and I'll see if I can get around to making an example for it. T
Sep 25 2017
On Mon, Sep 25, 2017 at 03:41:14PM +0000, WhatMeWorry via Digitalmars-d-learn wrote:On Monday, 25 September 2017 at 06:07:58 UTC, H. S. Teoh wrote:https://github.com/dlang/dlang.org/pull/1899 T -- If creativity is stifled by rigid discipline, then it is not true creativity.On Mon, Sep 25, 2017 at 05:28:13AM +0000, WhatMeForget via Digitalmars-d-learn wrote:Thanks. I just created my first enhancement request, issue 17856.[...]You're not the only one. I stared at this same piece of documentation for a long time before I figured out what it meant. This is another example of poor documentation writing. Please file a bug, and I'll see if I can get around to making an example for it. T
Sep 25 2017
On Monday, September 25, 2017 05:28:13 WhatMeForget via Digitalmars-d-learn wrote:This is taken exactly from the traits documentation. ------------------------------------------------ 25 Traits 25.21 identifier Takes one argument, a symbol. Returns the identifier for that symbol as a string literal. ------------------------------------------------ There are no examples. My naive brain keeps thinking that a symbol and an identifier are the same things. Can someone give me good definitions of "symbol" and "identifier". And maybe an example if it is not too much trouble.Think of the identifier as the name for the symbol and the symbol as what the compiler is actually operating on. Typically, a symbol either has a type or is a type, whereas an identifier is just a name. For instance, when the compiler sees an identifier in your code, it has to look it up to figure out what its corresponding symbol is (and you'll get a compiler error if it can't figure out which symbol you mean - be it because there is no such symbol, the symbol hasn't been imported, the symbol is inaccessible, or because there are multiple symbols that you could be refering to, and there isn't enough information for it to know which you meant). Regardless, there really should be more examples on that page. - Jonathan M Davis
Sep 25 2017