Porting D2 code to D1

Bill Baxter dnewsgroup at billbaxter.com
Wed Jul 16 12:31:15 PDT 2008


Jason House wrote:
> It may sound backwards, but I think it may be the best way to get things like Tango to move forward to D2.
> 
> Tango officially supports D1.  If it were to add D2 support, someone would have to port the D1 code to D2.  Then, with each change, a similar change must occur to the D2 code base.  From a maintenance standpoint, this really shouldn't be acceptable.
> 
> Since adding concepts such as const to D1 code in an automated fashion is essentially impossible, it seems the best approach is to convert D2 code into D1 code.  Programatically, it should be pretty easy to remove const-awareness.  That'd allow Tango to convert to D2 once and then (more or less) maintain one code base.
> 
> Maybe this would require a few special cases with D1-specific and D2-specific code, but I'd hope that wouldn't be very common.  I guess I have a few questions:
> 
> 1. Besides const removal, what else must get done to convert D2 code to D1 code?
> 2. How can D version-specific code be mixed into a single code base?
> 3. Any thoughts on how to programatically do all the conversions?
> 4. Would this be enough for D1 library maintainers to move to D2?

I was going to suggest using some sort of pre-processor but I think that 
is only a reasonable solution if everyone is on the same page that 
supporting both D1 and D2 is important.  In practice I think the current 
situation is more that there are devs who aren't interested in D2 and 
there are those who aren't interested in D1.  And neither group will be 
satisfied having to tart up the source code with pre-processor macros in 
order to make it work with the "other" version.

Also having to make the same code base compatible with both is 
increasingly going to mean crippling the D2 version, as D2 accumulates 
more and more tricks that are just impossible with D1. Like partial 
IFTI, which now works in D2 and is used heavily in Andrei's std.algorithm.

So I think probably forking is more realistic. That way the people who 
are wild about D2 are free to come up with solutions that make the most 
sense in D2 without having to worry about whether it will work in D1 or 
not.  Advances in D1 Tango can be ported forward as seems fit.  Maybe if 
you wait until Tango is officially 1.0 then the number of such changes 
will begin to taper off.  But I think it may be best to not put *too* 
much effort into making a D2 Tango "compatible" with D1 Tango.  Of 
course making it wildly different for no reason is also not a good idea.

--bb



More information about the Digitalmars-d mailing list