Arrays vs slices

bearophile bearophileHUGS at lycos.com
Thu Jun 11 05:02:24 PDT 2009


Steve Schveighoffer:
> No, please no!  Do I really need to carry around an integer that is going 
> to be unused 99.9% of the time (In my case, probably 100%)?  I'd rather 
> have a special type that has a stride.

Strides aren't essential, but once in a while they are useful, I use them now and then in Python. How can you tell that you don't need them so strongly?
But I agree that passing 3-structs is slower than 2-structs (having a "slice with stride" type in some standard library can be enough).


> Would be nice to specify an allocation strategy for 
> arrays too, so we can avoid some of the issues being discussed about the 
> GC allocating gigabytes for a 40MB array.

Just fixing the bug and putting there a sensible default seems more than enough to me. Variable allocation strategies are fine for library-defined arrays, but built-ins are better kept simple and flexible and efficient.

Bye,
bearophile



More information about the Digitalmars-d mailing list