Kagamin Wrote:

> And you'd better get acquainted with
> http://www.digitalmars.com/d/2.0/template.html
> http://www.digitalmars.com/d/2.0/template-mixin.html
> http://www.digitalmars.com/d/2.0/templates-revisited.html
> http://www.digitalmars.com/d/2.0/variadic-function-templates.html
> http://www.digitalmars.com/d/2.0/template-comparison.html
> and figure out whether you proposal barely covers all D templates use cases.

I have read all those pages. My proposal would be compatible with them. About 
your other question, instead of writing:

T Square(T)(T t)
{
    return t * t;
}

writefln("The square of %s is %s", 3, Square(3));

we would write:

T Square(type T, T t)
{
    return t * t;
}

writefln("The square of %s is %s", 3, Square(3));

If a non-type argument is used in place of a type that will occur later in the 
parameter list, we just skip the type and infer it later. It works just as well 
as the current approach. If you think it would be too confusing, you can put 
all your types before any non-types; it would just be syntactic sugar on what 
we have now.

--Sam

Reply via email to