Problem with const correctness

bearophile bearophileHUGS at lycos.com
Fri Dec 7 08:42:18 PST 2012


H. S. Teoh:

> Workarounds:
> - Use items.dup. Problem: if you're passing an actual array to 
> the ctor,
>   it's unnecessary and inefficient.
>
> - Use an array literal: auto x = Array!int([1,2,3]);, which I 
> believe
>   should allocate the array on the heap, and so you're safe to 
> just copy
>   the slice. This defeats the purpose of the "items..." syntax, 
> though.

I think the right solution is to fix the design+compiler, because 
it's safer.

(But how do you get the original GC-less behaviour if you need 
max performance and you know what you are doing?)

Bye,
bearophile


More information about the Digitalmars-d mailing list