On Friday, October 4, 2019 1:22:26 PM MDT Dennis via Digitalmars-d-learn wrote: > On Friday, 4 October 2019 at 19:08:04 UTC, Adam D. Ruppe wrote: > > (personally though I like to explicitly slice it all the time > > though, it is more clear and the habit is nice) > > Turns out I have this habit as well. I'm looking through some of > my code and see redundant slicing everywhere.
Really, it should be required by the language, because it's not something that you want to be hidden. It's an easy source of bugs - especially once you start passing that dynamic array around. It's incredibly useful to be able to do it, but you need to be careful with such code. It's the array equivalent of taking the address of a local variable and passing a pointer to it around. IIRC, -dip1000 improves the situation by making it so that the type of a slice of a static array is scope, but it's still easy to miss, since it only affects @safe code. It should certainly be possible to slice a static array in @system code without having to deal with scope, but the fact that explicit slicing isn't required in such a case makes it more error-prone than it would be if explicit slicing were required. - Jonathan M Davis