December 10, 2013 2.0.64 progression | ||||
---|---|---|---|---|
| ||||
This morning I decided to use 2.0.64 (well actually, git HEAD) to recompile a project that's been on the backburner for a while, and at first it appeared as though a regression has occurred, as dmd spewed out a screenful of compile errors.
Upon closer inspection, though, the errors were caused by several if-conditions of the following sort:
if (someCondition &&
cast(bool)(ptr = getPtr(...)) && // <--- compile error here
...)
{ ... }
These compile errors forced me to rewrite these lines as:
if (someCondition &&
(ptr = getPtr(...)) !is null &&
...)
{ ... }
Which, I'm sure you'll agree, is far clearer in intent, and less prone to unexpected bugs.
So this isn't a regression; it's *pro*gression!
(And on that note, I'd like to propose that code breakage of this sort *should* be allowed in D. While we *should* be stabilizing the language, I don't think it's right to go to the opposite extreme of hindering language fixes just so badly-written code will continue to compile. Better to get user code cleaned up of similar unsafe practices than to allow backward compatibility to hold back D progress!)
T
--
What do you call optometrist jokes? Vitreous humor.
|
December 10, 2013 Re: 2.0.64 progression | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | H. S. Teoh: > So this isn't a regression; it's *pro*gression! > > (And on that note, I'd like to propose that code breakage of this sort > *should* be allowed in D. While we *should* be stabilizing the language, > I don't think it's right to go to the opposite extreme of hindering > language fixes just so badly-written code will continue to compile. > Better to get user code cleaned up of similar unsafe practices I think this is another example of the same: https://d.puremagic.com/issues/show_bug.cgi?id=4733 Bye, bearophile |
Copyright © 1999-2021 by the D Language Foundation