[dmd-internals] Memory Leak

Daniel Murphy yebblies at gmail.com
Sun Nov 11 20:49:15 PST 2012


On Mon, Nov 12, 2012 at 1:51 PM, Jason House <jason.james.house at gmail.com>wrote:

> On Nov 11, 2012, at 8:38 PM, Walter Bright <walter at digitalmars.com> wrote:
> >
> > Yes, adding const in would probably be an easy and effective change. Too
> bad C++ has no purity :-(
>
>
> I've always thought an up and coming language should have a tool to
> automatically convert to C or C++ code. That allows support for all
> platforms supported by C/C++ and making a self-hosted compiler.
>
> How hard would a D to C++ converter be? I think ABI compatibility would be
> impossible, but might not be too big of a limitation. If such a thing
> existed, is it possible to incrementally convert pieces of the compiler to
> D?
>
>
I have in the past explored two other options:

1 - Automatically convert the compiler to D.  I had a go at this a while
back with quite impressive results.  dmd only uses a small, D-like subset
of C++ which makes it possible.  I managed to generate d code for the
frontend with some minor tweaks, then got stuck on the backend's prolific
use of #ifdefs halfway through expressions.  This is not insurmountable,
you just need to process the #ifdefs before trying to parse the code
instead of trying to convert them to static if/version.  At that point, I
took a break to explore:

2 - Enhance D's ability to link with a subset of C++, then refactor the
compiler until parts can be pulled out and ported to D.  The ultimate goal
would be to have the backend as a C++ static lib that is linked against a
frontend written in D.  I did a little bit of work on this at the beginning
of the year but reached the limit of my backend knowledge, this needs debug
info/mangling/codegen support.

On 11/11/2012 6:51 PM, Jason House wrote:

> How hard would a D to C++ converter be? I think ABI compatibility would be
> impossible, but might not be too big of a limitation.


My experience with the microd experiment shows that creating a D to C++
converter is not actually that difficult, so long as you're not trying to
produce idiomatic (or even readable) C++.  Most of D's features can be
lowered to C++ features (because they are C++ features).

On Sunday, November 11, 2012 19:54:30 Walter Bright wrote:
> On 11/11/2012 6:51 PM, Jason House wrote:
> > If such a thing existed, is it possible to incrementally convert pieces
of
> > the compiler to D?
>
> That would leave the specter of having two headers for the data types, one
> in D and one in C++.

Header generation can be automated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-internals/attachments/20121112/78176a5e/attachment-0001.html>


More information about the dmd-internals mailing list