Some more template syntax sugar

Derek Parnell derek at nomail.afraid.org
Mon Aug 28 18:00:25 PDT 2006


On Mon, 28 Aug 2006 22:18:04 +1000, Reiner Pope wrote:

> I think function templates still require too much in the way of type 
> annotations. Take the canonical example, sqr:
> 
> T sqr(T) (T x)
> {
> 	return x*x;
> }
> 
> In this example, we have to declare T three times, even though I think 
> this could be inferred. I propose an alternative syntax:
> 
> auto sqr(x)
> {
> 	return x*x;
> }
> 
> which IMHO looks very elegant.

It does! At first glance, this looks quite a natural consequence of the way
the D language is heading.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
29/08/2006 10:59:17 AM



More information about the Digitalmars-d mailing list