Template instantiation syntax

Christopher Wright dhasenan at gmail.com
Sat Oct 11 21:16:36 PDT 2008


Nick Sabalausky wrote:
> "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.

You can define a context-free grammar that accepts all syntactically 
correct C++ programs. This will accept many incorrect C++ programs, 
though, and you have to defer a lot of checking until the semantic phase.

The same is true of D. It's a question of how much checking has to be 
deferred, and whether a reasonably complete AST can be created from a 
context-free grammar. I don't know where C++ falls.

>>>> 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".

Hm. VB.NET can do just about everything that C# can. I can read C# 
easily. It takes a significant amount of effort for me to read VB.NET.

> 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