Why can't templates use tuples for for argument types?

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Jul 17 15:34:30 PDT 2007


"BCS" <ao at pathlink.com> wrote in message 
news:ce0a3343bf268c99691d2e8b71a at news.digitalmars.com...
>
> How did you hack my system!!!! I'm sure you copied that right off my hard 
> drive }:-|
>
> <g>
> All joking aside, I keep running into that so often that I want a cleaner 
> way to do it. I want the proper usage documented in the code, not the 
> comments and the asserts. I want to be able to talk about things by name 
> without having to make aliases. It's a minor point but...
>

The issue is that there's currently no way to specify that a template 
parameter can be 'anything'.  T means it's a type, alias T means it's a 
symbol, and <sometype> T means it's a value.  If you could specify that a 
parameter could take anything, this would be trivial.  How about using .. - 
it means it's kind of like a tuple, but shorter ;)

template Foo(A.., B...)
{

}

Or, take a page from Erlang:

template Foo(A | B...)
{

}

In this case, A can be anything, and not just a type, because it's on the 
left of a bar.  An issue with this, however, is that you can't have a type 
parameter. 




More information about the Digitalmars-d-learn mailing list