Real beginner traits question
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Mon Sep 25 08:30:44 UTC 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
More information about the Digitalmars-d-learn
mailing list