In C, one can declare that an input for a function is a constant pointer. The function can read from it, but not write to it. Is there an equivalent in Julia?
Context: I’m writing a function,
foo, that takes in a user’s function,
bar with some arguments, and I want to make sure
bar isn’t modifying the arguments that
foo is giving it. Those arguments can consist of mutable composite types of arrays and such things that might be easily overwritten.
I could create a deep copy before passing it in, but this seems like extra work – these arguments might become very large.
Here’s the pattern:
function foo(bar) ins = go_get_a_bunch_of_structured_data() outs = bar(ins) # Could use deepcopy, but that takes a long time. something_else(ins) # Hopefully not changed by 'bar'! end