---
# System prepended metadata

title: 'Open Discussion: Immutable and explicit copies'

---

# Open Discussion: Immutable and explicit copies

*These are collaborative notes from the open discussion round about "Immutable and explicit copies" at the [Solidity Summit 2020](https://solidity-summit.ethereum.org/).*

## Explicit copies
The `copyof x` syntax
- Current assignment semantics are already confusing. The added clarity would be worth the verbosity.
- Making copies explicit is in itself a good idea but the weird semantics of the copy operator might themselves add more confusion.

## "Pure" functions and mutable references
`mutable`/`immutable` could alternatively be specified at the call site.

## Immutable variables
Putting `mutable` everywhere would be verbose. People would have to adjust to the new style of writing code.

## Complex example

```
uint[] s1;

function f(uint[] immutable a) pure returns (uint ret) {
  ret = a[0];
  ret = a[1];
}

function g(uint[] mutable a) {
  a[1] = 1;
  a[2] = 3;
}

function h() {
  uint[] storage s2 = ref s1;
  uint[] mutable memory a = copy s2;
  uint[] immutable memory b = copy s2;

  f(a); // works
  f(copyof a); // works
  
  g(a); // works
  g(copyof a); // works

  g(b); // fails
  g(copyof b); // works?
}
```
