# Why I can't set what parameters are mutable explicitly?

**URL:** https://discourse.julialang.org/t/why-i-cant-set-what-parameters-are-mutable-explicitly/86091
**Category:** Offtopic
**Tags:** functions
**Created:** [August 21, 2022, 3:50pm UTC](https://discourse.julialang.org/t/why-i-cant-set-what-parameters-are-mutable-explicitly/86091 "2022-08-21T15:50:10Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)
#### Post date: [August 21, 2022, 4:54pm UTC](https://discourse.julialang.org/t/why-i-cant-set-what-parameters-are-mutable-explicitly/86091/9 "2022-08-21T16:54:00Z")

</div>

> [@mkitti](#):
>
> Try a `ReadOnlyArray` then:

Great suggestion. Shouldn’t it be possible then to write a small macro `@immutable` that would be used as in the following?

```julia
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:

```julia
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.

---

_[View the full topic](https://discourse.julialang.org/t/why-i-cant-set-what-parameters-are-mutable-explicitly/86091)._
