www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Re: Invalid bounding interval [, ]

 1) How come you can omit parentheses for uniform's
 parameter, shouldn't it be
  uniform!("[]")(...) ?

I think I can answer this. With ! already being used, it already knows it's a template and is separating your argument. Being as you only have 1 argument, it's allowed. That's why you can see to!string(x) and to!(string)(x). At least that's how I understand it. If you have more than 1 argument for your template say for 'T2 fromTo(T, T2)(T t)', it has to be in parentheses. Not only would something like 'fromTo!int!string(x)' be difficult to read (and ugly, feels like :: for c++), it would probably be a pain on the compiler and syntax checker. So the second one would be 'fromTo!(int, string)(x)'. Etc. A good number of things are syntactical sugar, making lives easier :)
Jan 25 2012