foo!(bar) ==> foo{bar}

KennyTM~ kennytm at gmail.com
Wed Oct 8 09:21:01 PDT 2008


Andrei Alexandrescu wrote:
> Alexander Pánek wrote:
>> Steven Schveighoffer wrote:
>>> "Alexander Pánek" wrote
>>>> Steven Schveighoffer wrote:
>>>>> Everything runs together, looks like one big word.  I think we need 
>>>>> a full height character to represent template brackets, something 
>>>>> with a lot of whitespace to separate it from the other characters.
>>>> Heh... sounds like !() to me! ;)
>>>
>>> *gasp*  That's perfect!  I say we go with it ;)
>>
>> Has my vote, for sure!
> 
> One possibility to make progress would be to keep !( but allow omitting 
> the parens when only one argument is being passed. That way many 
> instantiations will be helped. For example, in wake of the impending 
> demise of complex built-ins:
> 
> Complex!double alpha;
> Complex!float[] data;
> 
> That way, again, we leverage the fact that an extra symbol is needed 
> instead of compulsively requiring it in addition of the parens.
> 
> One nice thing about this change is that it keeps all code as it is, 
> just lifts one restriction.
> 
> How about that?
> 
> 
> Andrei

vote++ for this.

But how do templates with no arguments be called? Is “T!” valid? If so, 
can these ambiguity be solved first? These are minor cases, though.

(1) opCall strikes again!

class T(int n = 6) {
         static int opCall (int z) {
                 writefln(z);
		return z;
         }
	static char init;
}

void main() {
	auto x = T!(4).init;
}

(2) !is

template T() {
	enum T = 3;
}

void main () {
	writeln(T!is 3);
}



More information about the Digitalmars-d mailing list