www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - 2.0.64 progression

reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
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.
Dec 10 2013
parent "bearophile" <bearophileHUGS lycos.com> writes:
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
Dec 10 2013