The branch on the first version will be eliminated. The second version is
far more idiomatic, however. Consider that the second version is trivially
extensible to more types while the first version cannot be extended at all.
On Tuesday, September 29, 2015, Matt wrote:
> I
As Stefan mentioned, the `@generated` function below is equivalent to the
first function you posted, except that it is worse style since it is not
extensible, will generally require more memory, it is less readable (and it
seems to be giving the wrong answer for N > 2 and N == 0?)
The Julia-style
Hey,
Sorry I'm not sure what you're referring too.
Just to clarify. I have written 3 functions in the first subject. The first
function uses run time dispatch, the second use sub-auxiliary functions at
every differing line, the third uses the @eval style. I like the syntax of
the first
Thanks for answering. Sorry I deleted my question after finding what I
wanted. If some people are interested, I like the two solutions below:
for t in (Vector, Matrix)
@eval begin
function f2(x::$t)
println("I'm an array")
$(t == Vector ? :(println("I'm a