Template instantiation syntax

Dave Dave_member at pathlink.com
Sat Oct 11 14:10:45 PDT 2008


"Benji Smith" <dlanguage at benjismith.net> wrote in message 
news:gcr39f$1qrm$1 at digitalmars.com...
> KennyTM~ wrote:
>>> I hadn't seen this mentioned lately; C#, Java and now C++0x are able to 
>>> work around the '> >' issue and allow '>>'.
>>>
>>> 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.
>
> I sympathize, because I actually prefer the Foo<Bar> syntax for template 
> declarations.
>

That's the biggest reason I mentioned it, because others may prefer it and 
because people were discussing other alternatives that I didn't like at all.

Personally I don't have any problem with the !(), and really don't see any 
reason to change it, at all, including the new shortened foo!bar.

> But it's not a question of it being *harder* to parse, or Walter being 
> "lazy". The only way to resolve the ambiguity in the parser would be to do 
> semantic analysis during the lexical phase.
>
> I've worked with a few open-source Java parsers, and ">>" is always 
> recognized as a right-shift operator during tokenization. But then, if the 
> statement doesn't make any sense, the semantic analyzer can rewrite the 
> token stream. (I don't know how Sun does it, but I imagine it's something 
> like that.)
>
> As much as I like the angle-bracket template syntax, I think it's a good 
> choice to get rid of that ambiguity.
>

My thoughts exactly when I first read: 
http://www.digitalmars.com/d/2.0/templates-revisited.html

> One of the best parts of the D language design is that it's lexically 
> unambiguous, so tokenization, syntactic analysis, and semantic analysis 
> can be completely separate from one another.
>
> --benji 




More information about the Digitalmars-d mailing list