What are the worst parts of D?
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Tue Sep 23 17:06:25 PDT 2014
On Tue, Sep 23, 2014 at 11:25:52PM +0000, deadalnix via Digitalmars-d wrote:
> On Tuesday, 23 September 2014 at 20:22:32 UTC, H. S. Teoh via
> Digitalmars-d wrote:
> >SFINAE is another dark corner of disaster waiting to happen, once we
> >decide to implement C++ template compatibility. As well as Koenig
> >lookup, which will become indispensible if D code is to actually use
> >non-trivial C++ libraries.
> >
>
> We don't need these to be compatible with C++. We don't want to
> be able to cut/paste C++ into a . file and expect it to compile,
> but that you can map a reasonable amount of C++ constructs and
> expect them to interact with the C++ code and back.
You *will* need SFINAE if you expect to interface C++ template libraries
with D. Imagine that an existing codebase is using some C++ template
library that depends on SFINAE. You'd like to start migrating to D, so
you start writing new code in D. Eventually you need to make use of the
C++ template library in order to interface with the C++ parts of the
code, so you write a .di that declares template functions in an
extern(c++) block. It works... some of the time. Other times you start
getting weird errors or the wrong functions get called, because the C++
template library was written with SFINAE in mind, but D doesn't have
that. So at the end of the day, it's a gigantic mess, and you go
crawling back to C++.
Unless, of course, we draw the line at templates and say that we won't
support template compatibility with C++ (and I'd fully support that
decision!). But that means we throw all C++ template libraries out the
window, and any C++ codebase that makes heavy use of a template library
will have to be rewritten from scratch in D.
As for Koenig lookup, you might run into problems if you declare C++
wrappers for D functions in the C++ part of the codebase, and suddenly
the wrong D functions are getting called due to Koenig lookup in C++
which wasn't considered when the D part of the code was written.
T
--
Без труда не выловишь и рыбку из пруда.
More information about the Digitalmars-d
mailing list