Thread overview
porting c++ code to dpl
Aug 06, 2011
Mirko Pilger
Aug 06, 2011
Simon
Aug 06, 2011
bearophile
Aug 06, 2011
Simon
August 06, 2011
hello everybody,

i'm new to this language and plan to start learning it by porting parts of an existing c++ library to dpl.

i would very much appreciate it if you have some tips & tricks, hints of pitfalls or any other experiences to share.

mirko
August 06, 2011
On 06/08/2011 17:59, Mirko Pilger wrote:
> hello everybody,
>
> i'm new to this language and plan to start learning it by porting parts
> of an existing c++ library to dpl.
>
> i would very much appreciate it if you have some tips & tricks, hints of
> pitfalls or any other experiences to share.
>
> mirko

Well I've ported quite a bit of C++ code to D.
And on the whole I'd say that there isn't really much to say.

Most of the issues I've hit have been bugs in dmd or optlink;
which clearly have nothing to do with the language itself.

Unless you need pointer to members/pointer to member functions, just about every bit of c++ is easier and more straight forward in D.

Just plough ahead and ask questions if you hit an issue.

-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
August 06, 2011
Simon:

> Unless you need pointer to members/pointer to member functions, just about every bit of c++ is easier and more straight forward in D.

I have had some problems when the original C++ code uses struct inheritance ("alias this" helps a bit) or multiple inheritance.

Bye,
bearophile
August 06, 2011
On 06/08/2011 19:07, bearophile wrote:
> Simon:
>
>> Unless you need pointer to members/pointer to member functions, just
>> about every bit of c++ is easier and more straight forward in D.
>
> I have had some problems when the original C++ code uses struct inheritance ("alias this" helps a bit) or multiple inheritance.
>
> Bye,
> bearophile

Most well written C++ only uses MI for pasting methods into classes; you can mostly re-factor code like that into template mixins.

When I've come across C++ which isn't easily convertible to D, then the original code itself is badly written and badly designed anyway, so I don't even want to port it.

Easier just to write it again in D

-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk