Arrays, overlapping, etc

Vladimir Panteleev thecybershadow at gmail.com
Mon Jul 9 12:24:45 PDT 2007


On Mon, 09 Jul 2007 20:15:19 +0300, Regan Heath <regan at netmail.co.nz> wrote:

> Vladimir Panteleev wrote:
>> The main reason for overlapping copy being forbidden is because
>> forbidding it makes normal array operations much faster - the
>> compiler doesn't have to check for overlaps each time an array
>> (slice) is copied.
>
> Isn't it already checking?  I mean, it has to be in order to give the
> exception "overlapping array copy", right?

It only does that in debug versions. If you compile a release build, stuff will just break.

>> I made a suggestion some time ago to make the
>> compiler allow overlapping copy when it's obvious that you're doing
>> it (copying a slice of one array onto itself). No one has yet
>> discussed implementing it as a separate language feature, though.
>
> I dont want a seperate language feature.  I just want it to work.

Don't think it's possible to do without the abovementioned performance penalty with all array slice copies.

-- 
Best regards,
  Vladimir                          mailto:thecybershadow at gmail.com



More information about the Digitalmars-d mailing list