That depends very much on whether Julia can figure out exactly how many elements are in the array that's being splatted or not. The type of structure you're splatting matters too. In general, you should avoid it where possible, especially constructing an array and then splatting it into a function call. Splatting multiple return values (i.e. a tuple) from a function into the argument list of a function call is often ok, however.
On Thu, Apr 3, 2014 at 6:55 PM, Paweł Biernat <[email protected]>wrote: > That's very impressive. I used Sequence in Mathematica a lot and its good > to know Julia implements similar functionality. What is the overhead for > "..."? For example in the case of hcat([i for i=1:3]...). Is it going to > be as fast as writing the arguments explicitly like in hcat(1,2,3)? > > W dniu czwartek, 3 kwietnia 2014 22:10:08 UTC+2 użytkownik Ethan Anderes > napisał: > >> I don't know mathematica but it looks like ... does the same thing. I use >> it often when I have a function that has a lot of arguments. >> >> function foo1(x,y,z,w) >> sin(x+y+z+w) >> end >> >> fin = [ >> 3, >> 4, >> 5, >> 6 >> ] >> >> foo1(fin...) >> >> It also works for keyword args >> >> function foo2(;x = 1, y = 2, z = 3, w = 4) >> sin(x+y+z+w) >> end >> >> fin = [ >> :x => 3, >> :y => 4, >> :w => 5, >> :z =>6 >> ] >> >> foo2(;fin...) >> >> Cool, right? >> >>
