Using _concrete_ parametric types is the way to go---the compiler will
generate all those different function versions for you. Check out the sections
in the FAQ (part of the manual) that discuss how types interact with the
compiler, those should answer your questions.
--Tim
On Tuesday, November 26, 2013 09:22:11 PM Trendy Moniker wrote:
> Hi Stefan,
> Thanks for the quick reply. It's quite helpful. If there's a brewing FAQ
> post, I'd suggest also adding a link to the section on parametric composite
> types<
http://docs.julialang.org/en/latest/manual/types/#parametric-composite
> -types>which talks about this very issue (and which I just found for the
> first time in the intervening hour -- my apologies for the spam).
>
> I'm still a bit confused on what best practices are for this code pattern.
> The style guide says to avoid overly specific
> types<
http://docs.julialang.org/en/latest/manual/style-guide/#avoid-writing
> -overly-specific-types>, and not to use unnecessary static
> parameters<
http://docs.julialang.org/en/latest/manual/style-guide/#don-t-us
> e-unnecessary-static-parameters>. At the same time, the parametric composite
> types<
http://docs.julialang.org/en/latest/manual/types/#parametric-composit
> e-types>entry suggests that there can be significant performance hits for
> declaring arrays of abstract types. My initial impression had been that a
> definition like function do_stuff2{T<:Integer}( m::Matrix{T} ) caused the
> compiler to create one version of the function for each concrete type under
> Integer, (e.g.: Int8, UInt8, Int16, etc.) but reading the parametric
> composite
> types<
http://docs.julialang.org/en/latest/manual/types/#parametric-composit
> e-types>entry and looking at methods(do_stuff2) makes me think that was
> > <
trendy...@gmail.com<javascript:>>