D1 -> D2

Jacob Carlborg doob at me.com
Thu Nov 18 08:33:46 PST 2010


On 2010-11-18 11:51, Fawzi Mohamed wrote:
> Is there any "porting" guide around in a wiki?
> If not a page where to share the best tricks would be nice "D1->D2
> conversion tricks"?
>
> In the short term I don't think that going D2 only is really an option
> for me, so how feasible it is to keep the code base compatible to both
> D1 and D2?
>
> I know that one can define some templates (for example Const(T),....),
> and maybe use mixins, but how much uglier does the code become as result?
> I choose D to have cleaner code, I am not interested in loosing all that
> just to be D1 and D2, then I prefer to wait, and convert everything at
> once.
>
> Well that is about it...
>
> thanks
>
> Fawzi

The experience I have with this is the Orange library which supports 
both D1 (Tango) and D2. I say this: it can sometimes be surprisingly 
easy and sometimes a PITA.

Depending on what you do you can get a long way with aliases, I have for 
quite a long time now been using a string alias in D1 (I just like it 
better than char[]).

For some things you will have to use string mixins and after some 
testing with Derelict2 we found out that it's better to use few string 
mixins containing a lot of code than many string mixins containing just 
some code. Otherwise the compile time will increase, sometimes quite a lot.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list