Template instantiation syntax

Dave Dave_member at pathlink.com
Sat Oct 11 13:33:13 PDT 2008


"Nick Sabalausky" <a at a.a> wrote in message 
news:gcqvfr$1k6i$1 at digitalmars.com...
> "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.
>

I can see your point and to a point I think it is a valid concern.

But, most users could care less about that stuff IMO. Abstraction from what 
a compiler does is why we use higher-level languages in the first place <g>

I'd argue that it's more important to have demand for a language than to 
make it easy on the compiler writers and language designers but I agree 
there has to be a balance.

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

I agree; in an earlier post I questioned any need for deviating from the 
current syntax. But if the concensus is that a change is needed, all I'm 
arguing is that it should be towards other popular C-lineage language 
conventions rather than further from them. There are plenty of other even 
more important differences (even for just templates) that make D a better 
language, and easier to build a compiler for, for that matter.

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

For D, I see template syntax as closer to the nuclear plant than to the 
bikeshed in the scheme of things. Although by the amount of discussion this 
topic has generated, I can see your point <g>




More information about the Digitalmars-d mailing list