constraints,template specialization,drop IFTI
BLS
windevguy at hotmail.de
Wed Jul 15 10:33:49 PDT 2009
Daniel Keep wrote:
>
> BLS wrote:
>> I have somehow the idea that D constraints and template specialization
>> should merge.
>> Guess what I want to say is that instead of accepting the compiler
>> decision for template specialization a constraints could be used for :
>> "I am not the one who is able to fulfill your needs.. try this template
>> instead."
>>
>> template Foo(int N)
>> if ( ( N & 1 _else_ FooOdd!(int N)) )
>> {
>> ...
>> }
>
> Firstly, why not
>
> template Foo(int N)
> if( N&1 ) else FooOdd!N
> {
> ...
> }
>
> Secondly, why? I mean, isn't this equivalent to:
>
> template Foo(int N)
> {
> static if( N&1 ) { ... }
> else alias FooOdd!N Foo;
> }
>
>> ...
>>
>> A smarter implementation will probably support tuple based pattern
>> matching.
>
> Huh? Isn't this how template matching works anyway; match a given
> argument tuple against the available templates?
sure, but Mister Compiler makes that decision, What I want is _also_
programmer control.
template Foo(T : Tuple)
match T { case... }
{
//default
}
>
> Lastly, what's that in the subject about dropping IFTI? I seriously
> hope you're joking about that.
ok, wrong description, wrong words. should be -> make implicit function
template instantiation explicit :) work.
More information about the Digitalmars-d
mailing list