Thus is not an issue with pass-by-sharing so much as the existence of
mutable types. You can avoid needing to define (or use) the copy method by
structuring your logic to generally avoid mutating your data structures. I
know this may sound strange at first, but if you are going to be making
copies anyways, it makes a lot more sense to make them only when you were
about to make a modification, rather than every time you make a reference
to it (it's essentially implementing the copy-on-write optimization
implemented by some languages, without the need for a compiler optimization)


On Friday, August 15, 2014, Noah Brenowitz <[email protected]> wrote:

> Ok thanks. I guess  the heart of the question is overcoming Julia's
> builtin pass-by-reference behavior. I would be fine using an explicit copy
> function, but is there any way I can avoid defining a copy function for all
> my types, which would be annoying?
>

Reply via email to