shouting versus dotting

KennyTM~ kennytm at gmail.com
Mon Oct 6 06:04:46 PDT 2008


Benji Smith wrote:
> Andrei Alexandrescu wrote:
>> I'd want to give it a try. How do others feel about Template{arguments}?
> 
> 
> At first glance, I like it better than !(), especially since it saves a 
> character, making nested templates much nicer:
> 
>    auto map = new Map{T[], List{MyType}}();     // not too bad
>    auto map = new Map!(T[], List!(MyType))();   // not too good
>    auto map = new Map<T[], List<MyType>>();     // still my favorite
> 
> It's too bad the shift operators can't be changed. Personally, I think 
> the angle brackets are more valuable as a matched pair of enclosures.
> 
> We could redefine the shift operators to be:
> 
>    -->  RIGHT SHIFT
>    <--  LEFT SHIFT
>    -->> SIGNED RIGHT SHIFT
> 
> And then the angle brackets could be coopted for templates.
> 
> Of course, like I said before, I think it'd be especially cool if 
> templates, as such, didn't exist. Instead, what if an ordinary function 
> could return a Type, which could be used in a Type Constructor? 
> Templates would vanish! It'd be CTFE, but for types instead of just for 
> values.
> 
> --benji

Another problem with < is that, if you're not confident that Map is 
really a template identifier, you'll have the ambiguity whether < is an 
open bracket or a less than sign.

int x, y, w, z;

writefln(x<y,w>(z)); // currently compiles.



More information about the Digitalmars-d mailing list