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

Jarrett Billingsley jarrett.billingsley at gmail.com
Mon Oct 6 15:41:27 PDT 2008


On Mon, Oct 6, 2008 at 6:04 PM, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> 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.

Please to not having Perl in D.  I really like the idea of token
strings, but something like ${} would probably be better.

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

That's because nowhere else in the language is such a sequence of
characters interpretable as anything else :)



More information about the Digitalmars-d mailing list