What do you mean copying the object is inefficient? Do you mean that it is 
cheaper to build it from scratch than to start with the copy?

On Saturday, August 22, 2015 at 9:51:48 PM UTC+2, Timothée Poisot wrote:
>
> Hi, 
>
> I caught myself wondering about the "correct" way to use function and 
> function! -- or rather, how other people deal with this. 
>
> Let's say I have a simple function that operates on an array, and I 
> want a version to modify the original object, and one that doesn't. 
>
> Is this the correct way of doing it? 
>
> ~~~ 
> function baz!(x) 
>         # Do things on x 
> end 
>
> function baz(x) 
>         y = copy(x) 
>         baz!(y) 
> end 
> ~~~ 
>
> This allows to reuse the code of baz!, but copying the object IS 
> inefficient. How do you usually deal with this situation? 
>
> t 
>

Reply via email to