Thread overview
Real beginner traits question
Sep 25, 2017
WhatMeForget
Sep 25, 2017
rikki cattermole
Sep 25, 2017
H. S. Teoh
Sep 25, 2017
WhatMeWorry
Sep 25, 2017
H. S. Teoh
Sep 25, 2017
Jonathan M Davis
September 25, 2017
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.
September 25, 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
```
September 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.
September 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

September 25, 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:
>> [...]
>
> 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

Thanks.  I just created my first enhancement request, issue 17856.
September 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:
> > On Mon, Sep 25, 2017 at 05:28:13AM +0000, WhatMeForget via Digitalmars-d-learn wrote:
> > > [...]
> > 
> > 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
> 
> Thanks.  I just created my first enhancement request, issue 17856.

https://github.com/dlang/dlang.org/pull/1899


T

-- 
If creativity is stifled by rigid discipline, then it is not true creativity.