[dmd-beta] dmd 1.065 and 2.050 beta
Jonathan M Davis
jmdavisProg at gmx.com
Wed Oct 27 16:02:24 PDT 2010
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 (and the fact that string
literals are immutable on Linux but not Windows sure isn't going to help with
code portability). We really need to find a permanent solution for this problem
soon.
- Jonathan M Davis
More information about the dmd-beta
mailing list