Arrays, overlapping, etc

Xinok xnknet at gmail.com
Mon Jul 9 10:04:21 PDT 2007


I think a new method should be added to arrays for overlapped copies. 
Sometimes, an overlapped copy is required, and it would be nice if the 
language handled that for me.
The only deficiency is the check. Otherwise, it's just a matter of 
iterating the array forwards or backwards.

int[] a;
a[1..10].ocopy(a[0..9]);

Vladimir Panteleev wrote:
> On Mon, 09 Jul 2007 11:31:25 +0300, Regan Heath <regan at netmail.co.nz> wrote:
> 
>> The next point is that surely an overlapping copy can be implemented/handled?  I had a quick look in Bugzilla and found a couple of of items the topic and related topics.  One even suggests documenting the various methods you can use to get around the deficiency.
> 
> 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. 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.
> 



More information about the Digitalmars-d mailing list