array depth template
Saaa
empty at needmail.com
Thu Jun 11 20:45:32 PDT 2009
>> Any advantage to using two?
>
> I just tend to prefer template specialization when doing type pattern
> matching. It works out better than is() in some cases.
Looks very Haskell like :)
>
>> He also does : is( T B ==B[]) iso is( T B:B[] )
>> Any significant difference there?
>
> I'm.. not sure, in this case anyway. Normally == does strict type
> comparison while : does implicit type conversion, but in this case,
> is() is being (ab)used to pick apart a type rather than test one. I
> think it'll always return 'true' in either case if T is an array, so I
> don't think there's a functional difference.
Implicit convertion sounds a bit dangerous, might start using == instead
>
>> Also, what's the advantage of explicitly defining it as a template?
>
> As opposed to what, implicitly defining it as a template? This
> question doesn't really make sense.
I mean, I was using a function template.
> template ArrayDepth(T: T[]) { const ArrayDepth = 1 + ArrayDepth!(T); }
> template ArrayDepth(T) { const ArrayDepth = 0; }
The code looks a bit strange to me:
ArrayDepth is both a (const) value and template name and where is the return
value ?
More information about the Digitalmars-d-learn
mailing list