2.0.64 progression

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Dec 10 10:39:00 PST 2013


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.


More information about the Digitalmars-d mailing list