On Sunday, 29 December 2024 at 21:58:40 UTC, Renato Athaydes wrote:
I expected this to be accepted by the compiler:

```
void foo(const(char[]) c) {
  const(char[])[2] d;
  d[0] = c;
}
```


```d
void foo(const(char)[] c){
  const(char)[][2] d;
  d[0] = c;
}
```

*AND*

```d
void foo(const(char[]) c){
  const(char)[][2] d;
  d[0] = c;
}
```

*AND*

```d
void foo(const(char[]) c) {
  const(char)[][2] temp;
  temp[0]=c;
  const(char[])[2] d=temp;
}
```

compile

Why is this ok, but not the previous one?

I dont use const if I can help it so idk details; but slices are reference types theres probably some theory about how the length is spookily making promises about the data.

Maybe slices are the worse of both worlds of being reference and value types, according to extreme safetyism?

Reply via email to