variadic request on the wild side.

Fredrik Olsson peylow at gmail.com
Sat Aug 12 09:13:21 PDT 2006


Having a constructor like:

this (...) { /* some code */ }


Can be useful, but there is one problem. Lets say you expect floats, but 
then constants are by default double, so you have to cast them when 
passing them, or check and cast inside. The variadic function can become 
very complex.

What if I could specify a set of types that should be allowed? Say with 
this syntax as a suggestion:

this (...<int, Set!(int), Range!(int)>) { /* less code */ }

This way the compiler will limit the types that can be passed to the 
function, and the function (in this case a constructor) can be made much 
simpler.


// Fredrik Olsson



More information about the Digitalmars-d mailing list