foo!(bar) ==> foo{bar}

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Oct 6 15:04:22 PDT 2008


Ary Borenszweig wrote:
> superdan escribió:
>> bearophile Wrote:
>>
>>> Walter Bright:
>>>> The foo.(bar) syntax seems to be sinking.
>>> The Foo{bar} syntax looks nice enough, it's a char long, and I 
>>> presume q{int} isn't a problem, but from 30 answers seems people 
>>> don't see problems in the old syntax. So it's not sinking at all.
>>
>> relax. he said the pissed pirate is sinking not the slashed pissed fella.
>>
>> q{int} is a problem.
>>
>> template q(T) { enum q = "eh"; }
>> writeln(q{int});
>>
>> tat prints eh or int?
> 
> It prints "int", of course. q{int} is already evaluated at the lexical 
> pass, so the parser sees:
> 
> writeln("int");
> 
> I don't see it is such a big deal. Why would you define a template named 
> q anyway? No one will be bitten by that.
> 
> Although I know it's inconsistent... it's not "nice".
> 
> But !() is about to change in D2, why not change q{}, which is also D2 
> only?

I agree with superdan and Ary, q{string} is a mistake. I was behind 
introducing q{}, I apologize.

Speaking of constructs starting with letter, there's also r"string". So 
far it hasn't caused problems...


Andrei



More information about the Digitalmars-d mailing list