Dynamic array head const in library code?

2014-11-28 Thread bearophile via Digitalmars-d-learn
In D code it's a good idea to set as const/immutable (where possible) all variables that don't need to change, for both safety and compiler-enforced code documentation. In my D functions sometimes I create dynamic arrays that later don't have to change length nor to be reassigned, but I have to

Re: Dynamic array head const in library code?

2014-11-28 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Friday, 28 November 2014 at 10:55:27 UTC, bearophile wrote: In D code it's a good idea to set as const/immutable (where possible) all variables that don't need to change, for both safety and compiler-enforced code documentation. In my D functions sometimes I create dynamic arrays that later

Re: Dynamic array head const in library code?

2014-11-28 Thread bearophile via Digitalmars-d-learn
Dominikus Dittes Scherkl: Why you don't use static arrays for such a purpose? I thought this is exactly what they are made for, aren't they? Currently you can't create a static array with a length known only at run-time. And passing around a fixed-size arrays has some costs. Bye,

Re: Dynamic array head const in library code?

2014-11-28 Thread John Colvin via Digitalmars-d-learn
On Friday, 28 November 2014 at 10:55:27 UTC, bearophile wrote: In D code it's a good idea to set as const/immutable (where possible) all variables that don't need to change, for both safety and compiler-enforced code documentation. In my D functions sometimes I create dynamic arrays that later