I have some ideas from my experience in C++11, but I'd like to learn the 
proper "Julian" way :)

My goal is to implement a function that computes an Array. I do this if I 
want speed:

function computestuff!(A::Array{FloatingPoint,1})
    A=fill!(A,0); #reset array values
    #modify the contents of A
end


#in the calling routine...
A::Array{FloatingPoint,1}=Array(FloatingPoint,5);
computestuff!(A);

Question 1: Is there an even faster way in Julia?


Question 2: I wish to hide the details inside that function (i.e. allocate 
the size of A inside of the function) without sacrificing speed. This way, 
in the calling routine, I can just write

#in the calling routine...
A=computestuff(5);


Is this possible?
I think any new memory allocated inside that function will be 
undefined/freed once the function exits. If the pointer A is assigned to 
this memory, I'd get undefined results. Julia probably checks against this 
kind of situation and assigns a deep-copy instead, which slow things down.

Thanks!


Reply via email to