[dmd-beta] dmd 1.065 and 2.050 beta
David Simcha
dsimcha at gmail.com
Wed Oct 27 18:16:16 PDT 2010
On 10/27/2010 7:02 PM, Jonathan M Davis wrote:
> On Wednesday, October 27, 2010 14:33:17 David Simcha wrote:
>> I agree 100% that startsWith needs to work with immutable(X[]).
>> Nonetheless, the proper way to address this is by fixing the language, not
>> by relying on expedient bugs. I insisted on fixing this because history
>> has shown that if too many people start relying on behavior that is
>> clearly a bug but happens to be expedient, the bug becomes politically
>> unfixable no matter how wrong the behavior is. Fixing the rest of Phobos
>> such that startsWith() and similar functions will work with immutable(X[])
>> without relying on Bug 3534 would have been a monumental task (I tried).
>>
>> My proposal for dealing with this issue has always been that IFTI should
>> instantiate a function with an Unqual!(T) when passed a T, if and only if
>> the given T is implicitly convertible to Unqual!(T). For example:
>>
>> void foo(T)(T arg) {}
>>
>> immutable str = "A family of foxes found food in the forest.";
>> foo(str); // Equivalent to foo!(immutable(char)[])(str);
>>
>> immutable num = 2;
>> foo(num); // Equivalent to foo!(int)(num);
>>
>> const myRetro = retro([1,2,3,4,5,6]);
>> foo(myRetro); // const(Retro!(int[])) doesn't implicitly convert to
>> // Unqual!(const(Retro!(int[]))). No Unqual applied.
> Well, this change is going to break a lot of code
You're right, but it had to be done eventually and holding off and doing
it later would only break even more code.
> (and the fact that string
> literals are immutable on Linux but not Windows sure isn't going to help with
> code portability).
Since when are string literals not immutable on Windows? They
definitely are in D2.
> We really need to find a permanent solution for this problem
> soon.
Right. I've been somewhat disappointed that my IFTI proposal has
generated so little comment. IMHO it would solve a whole family of
issues related to the interaction between generic code and
const/immutable. These issues are so pervasive that std.math.pow()
didn't even work with immutable numeric primitives until a few releases
ago when I put in some kludges to make it work.
> - Jonathan M Davis
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>
More information about the dmd-beta
mailing list