Phobos - breaking existing code

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 28 16:04:46 PST 2014


On Sat, Nov 29, 2014 at 10:46:14AM +1100, Daniel Murphy via Digitalmars-d wrote:
> "Walter Bright"  wrote in message news:m5b0p2$1bv4$1 at digitalmars.com...
> 
> >Just for fun, I've decided to try and get MicroEmacs in D added to
> >the dub registry. The last time it compiled was 2 years ago.
> >
> >I wound up with at least a dozen references to Phobos names that have
> >disappeared. No corrective action was indicated, just "undefined
> >symbol".  I have to go refigure out what the code was trying to do,
> >and go poking through the Phobos documentation to see what will work
> >today.
> >
> >I know there's been a lot of "break my code" advocacy lately, but
> >this code was only 2 years old.
> >
> >I fully understand how unfriendly this is to users and how
> >discouraging it can be to have their recently working code shattered
> >and scattered. We need to do a lot better.
> 
> Two years is too old, you skipped all the deprecation stages.

>From an end user's POV, though, two years does seem like a short time. I
mean, I have C/C++ projects dating from 20 years ago, and you wouldn't
believe it, but almost all of them compile with no change on a modern
compiler. Granted, the comparison isn't altogether fair, since D is
changing a lot faster than C/C++, but still, 2 years is quite short from
that POV. Not everybody is constantly trying to compile code with git
HEAD and fixing compiling errors on every personal pet project they
have, that, on the off-chance, might stop compiling after 2 years.

Perhaps it's time to reconsider the length of the deprecation cycle,
from an end user's POV, rather than from the POV of the D devs who can't
wait to junk the old stuff and move on to the new.

Alternatively, we should have a "compatibility mode" for the compiler /
Phobos, where certain parts of the code are version'd out as they get
deprecated, but you can get them back by using an appropriate version
declaration:

	// Some phobos module
	version(PhobosCompat_2066)
	{
		// Old version - compile with version=PhobosCompat_2066
		// to get this symbol back
		auto oldSymbol(...) { ... }
	}
	else
	{
		// New version
		deprecated("Please use newSymbol instead.")
		auto oldSymbol(...) { ... }
	}

This works reasonably well for Phobos, but I don't know how to do this
in the compiler without ending up with an ugly plate of unmaintainable
spaghetti.


T

-- 
In theory, there is no difference between theory and practice.


More information about the Digitalmars-d mailing list