Fixing const arrays

Timon Gehr timon.gehr at gmx.ch
Sun Dec 11 12:57:58 PST 2011


On 12/11/2011 05:34 PM, Andrei Alexandrescu wrote:
> On 12/11/11 9:46 AM, dsimcha wrote:
>> On 12/10/2011 4:47 PM, Andrei Alexandrescu wrote:
>>> We decided to fix this issue by automatically shedding the top-level
>>> const when passing an array or a pointer by value into a function.
>>
>> Really silly question: Why not do the same for primitives (int, float,
>> char, etc.) or even structs without indirection? I've seen plenty of
>> code that blows up when passed an immutable double because it tries to
>> mutate its arguments. About 1.5 years ago I fixed a bug like this in
>> std.math.pow().
>
> Yes, that would be good to do as well.
>
> Andrei

+1. This also reduces template bloat, because IFTI wont create different 
instantiations when passed T, immutable(T), const(T).


More information about the Digitalmars-d mailing list