Any example of using these Special Tokens?
Jonathan M Davis
jmdavisProg at gmx.com
Wed May 25 01:42:43 PDT 2011
On 2011-05-25 01:29, Matthew Ong wrote:
> Hi,
>
> I am not able make use of these 3 special tokens to print something.
>
> writefln("gshared: %s",__gshared);
> writefln("thread: %s",__thread);
> writefln("traits: %s",__traits);
>
> ------------------------------------------------------------
> rc\Sample.d(128): expression expected, not '__gshared'
> src\Sample.d(129): expression expected, not '__thread'
> src\Sample.d(130): found ')' when expecting '('
> src\Sample.d(130): __traits(identifier, args...) expected
> src\Sample.d(132): found '}' when expecting ','
> src\Sample.d(146): expression expected, not 'EOF'
> src\Sample.d(146): found 'EOF' when expecting ','
> src\Sample.d(146): expression expected, not 'EOF'
> src\Sample.d(146): found 'EOF' when expecting ','
> src\Sample.d(146): expression expected, not 'EOF'
> ------------------------------------------------------------
>
> Would some like to show me how this is done??
They aren't printable. __gshared is a type. __traits is a function of sorts:
http://www.digitalmars.com/d/2.0/traits.html . I'm not sure what __thread is,
but I quite doubt that it's intended to be printable. Notice that the "special
tokens" __FILE__, __LINE__, etc. have underscores on _both_ sides. __gshared,
__thread, and __traits are different beasts entirely.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list