[dmd-beta] dmd 1.065 and 2.050 beta

Jonathan M Davis jmdavisProg at gmx.com
Wed Oct 27 22:21:04 PDT 2010


On Wednesday 27 October 2010 18:16:16 David Simcha wrote:
> 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.

It says it on the page for dmd: http://www.digitalmars.com/d/2.0/dmd-
windows.html :

String literals are read-only under Linux. Attempting to write to them will 
cause a segment violation.

> > 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.

I suspect that too many people just haven't been worrying about const or 
immutable much - either because they don't care about them or found them too 
much of a pain to use in the past and stopped messing with them. We definitely 
need to sort it out though, and if your proposed solution is a good one, then we 
really should look into it.

- Jonathan M Davis


More information about the dmd-beta mailing list