On Thursday, 7 August 2014 at 19:08:37 UTC, Johannes Blume wrote:
On Thursday, 7 August 2014 at 18:38:37 UTC, Marc Schütz wrote:
But this shouldn't be necessary, right? It's a mutable slice to immutable data, but the slice is passed by value, so no mutable sharing takes place.

The elements of the slice itself are mutable, you can e.g. assign some other string to args[1], which would be a potentially racy change among all threads which share that slice. Only the information "start address of slice" and "length of slice" are copied by value, which doesn't protect from this.

To be able to share the slice, it would need to be typed as "immutable(string)[]" instead.

Ah, indeed. It's mutable ref to mutable ref to immutable data.

Reply via email to