[Proposal] "Name inference" for function templates

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Fri Jun 16 05:28:55 PDT 2006


Andrei Khropov wrote:
> ------------------------------------------------
> template(T)
> {
> 	T sqr( T x )
> 	{
> 		return x*x;
> 	}
> }
> ------------------------------------------------
[snip]
> 
> This syntax also looks familiar to C++ guys ;-).

If you're going in that direction, you might want to also make the outer 
braces optional in this case, as they don't really add anything.

template(T) T sqr( T x )
{
	return x*x;
}

I think this would look cleaner, as well as even *more* familiar to 
people used to C++.



More information about the Digitalmars-d mailing list