Great suggestion. Shouldn’t it be possible then to write a small macro @immutable
that would be used as in the following?
function fun(a::AbstractVector, b::Real, c::AbstractVector)
@immutable a c
# From here on in the function, a and c are immutable
end
where the code generated by the macro would do something like the following:
a_orig = a # Or preferably gensym a random name
a = ReadOnlyArray(a_orig)
# and the same for c
Your thoughts?
Note: I didn’t supply actual code for the macro since my macro-foo is pretty weak. I could work out the correct code eventually, but hoping for you or some other wizard to whip it up in a few seconds.