On Thu, Jun 11, 2009 at 11:45 PM, Saaa<em...@needmail.com> wrote: >> 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
Um, there's no "one's better than the other." Don't overgeneralize on things you don't understand. Implicit conversion is necessary in some cases, and in others, exact comparison is needed. >>> 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. A function template is just a function in a template. Templates can work just fine on their own. If you're manipulating types, there's really no need to get functions involved. >> 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 ? See "Implicit Template Properties" here: http://www.digitalmars.com/d/1.0/template.html When you create a member in a template with the same name as the template, you can access it from the template without explicitly writing ArrayDepth!(int[]).ArrayDepth.