On Friday, April 15, 2016 21:16:44 Jonathan M Davis via Digitalmars-d wrote:
> On Thursday, April 14, 2016 09:31:25 Steven Schveighoffer via Digitalmars-d
>
> wrote:
> > That is awful.
> >
> > I propose we make slicing such a return value implicitly an error. I
> > can't think of a valid reason for allowing it.
> >
> > I'm not the only one: https://issues.dlang.org/show_bug.cgi?id=12625
>
> Totally agree, though I wish that we could take it one step further and get
> rid of the implicit slicing of static arrays. It's an unsafe feature, and
> once https://issues.dlang.org/show_bug.cgi?id=8838 has been fixed, and
> slicing a static array is flagged as @system, allowing the implicit slicing
> makes it really easy to miss that it's happening, and if multiple @system
> operations are happening in a function, the slicing of the static array
> could easily be missed by a programmer verifying the safety of the code in
> order to mark it with @trusted, whereas if the slice were explicit, it would
> be obvious. Unfortunately, I'm willing to bet that there's no way that
> Walter would give his okay on making the implicit slicing illegal because
> of how much code would break as a result.

Well, for whatever it's worth, I created an enhancement request. Maybe we'll
get lucky and be able to talk Walter into it:

https://issues.dlang.org/show_bug.cgi?id=15932

8838 and 12625 still need to be fixed regardless, but if we got rid of the
implicit slicing of static arrays, then you'd at least always be able to see
what's going on and more easily catch slicing-related bugs.

- Jonathan M Davis

Reply via email to