Template instantiation syntax

Nick Sabalausky a at a.a
Sat Oct 11 12:40:35 PDT 2008


"Dave" <Dave_member at pathlink.com> wrote in message 
news:gcqrbr$1cg4$1 at digitalmars.com...
> "KennyTM~" <kennytm at gmail.com> wrote in message 
> news:gcqnqd$161r$1 at digitalmars.com...
>> Dave wrote:
>>> a) It works for C++0x so it can be made to work for D using the same 
>>> rules. I also assume that C# and Java compilers use the same methods as 
>>> C++0x to work around the ambiguities with the right-shift operator.
>>
>> The argument against T<x> from the start is that it is more difficult to 
>> parse. It is not impossible, it is just difficult. You can blame Walter 
>> for being lazy.
>>
>
> Lazy doesn't mean to Walter what it means to the rest of us... To Walter, 
> "lazy" is another way of saying for "I don't agree and I'd rather just do 
> something else" <g>
>
> I just saw a post where Walter says he hates the angle brackets and that 
> syntax matters. I agree that syntax does matter, and apparently many 
> developers and other language designers don't have a problem with the "<>" 
> syntax. So maybe Walter needs to bite the bullet and D should just use it. 
> Maybe D is bucking a trend here where it shouldn't.
>

One of the original guiding principles of D is that it be easy to parse. 
There were a number of valid reasons for this, not just lazyness.

Plus, I'm no compiler expert, but I think I rememebr hearing somewhere that 
overloadng <> to be usable for both comparisons and grouping would require 
non-context-free grammar. That would be a major increase in D's parsing 
complexity. C++ grammer is definately not context-free, that's why it can 
get away with it. Not sure about C# or Java, but I've been under the 
impression those aren't context-free either.

>>> b) Easier and more natural for D newbies who've used C++ templates 
>>> and/or C# / Java Generics.
>>
>> I agree.
>>
>
> This is probably the biggest issue since D has to win mindshare or else 
> what is the point of this or any other discussion.
>

I consider this a non-issue. D is a different language, it's expected that 
certain things are going to be different. Otherwise it would be the same 
damn language. I had used C++ templates before I came across D, and my 
entire thought on it was just "Ok, C++ uses <>, and D uses !()". Done. It's 
no more of an issue than switching between Java's "{}" and ";" and VB.NET's 
"X...end X" and "newline".

D needs to win mindshare, sure, but there are better ways to do that than 
advertising a popular bikeshed color. 





More information about the Digitalmars-d mailing list