bearophile Wrote:

> bearophile:
> > Having a return also helps to see templates as closer to compile-time 
> > functions (changing few things there may be ways to merge the syntax of 
> > templates with the syntax of compile time functions, reducing the 
> > complexity of D).<
> 
> To write some templates as compile-time functions you may need to add a new 
> type to D, named "type":
> 
> type foo(type T) {
>     return T[];
> }
> 
> That is the same as:
> 
> template Foo(T) {
>     alias T[] Foo;
> }
> 

I'd love to see compile-time functions returning types. IMHO, it's far superior 
to the template-based approach. There are several reasons for this:

1. The template scheme violates the DRY principle. It's like type constructors 
in C++, Java, etc... D was designed to better than that! 

2. Function calls make it far clearer what the intent is. Once templates are 
allowed to have more members, the true purpose will be obfuscated.

3. It opens up possibilities for better (compile-time) reflection.

That being said, it's possible for templates to define an instance with unknown 
type and value. A non-templated function returning either a type or value can't 
do that.

Reply via email to