.NET on a string + bugs

bearophile bearophileHUGS at lycos.com
Tue Mar 17 10:29:59 PDT 2009


dsimcha:
>Nonetheless, D's arrays do have some rough edges.<

For the second time I have put a bug like this:

def foo(int[] a) {
  ...
  a.length = a.length - 1;
}

The length change can't be seen from the outside, because a is a struct passed by value. You have to use foo(ref int[] a). I think I'd like this to be the default behavior of dynamic array pass (disabled for example if you put an foo(in int[] a).
Do you add this bug to your programs too?


Steven Schveighoffer:
>I had a hackish scheme to use the most significant bit in the length field to identify if a slice is just beyond the allocated length.<

Such bit may also be stored in the pointer, if they are aligned to 8 or 16 bytes.

Bye,
bearophile



More information about the Digitalmars-d mailing list