What is going on in this code?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 15 21:16:44 PDT 2016


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.

- Jonathan M Davis



More information about the Digitalmars-d mailing list