Jump to page: 1 25  
Page
Thread overview
D vs C++ classes?
Jun 21, 2021
12345swordy
Jun 21, 2021
Meta
Jun 22, 2021
zjh
Jun 22, 2021
IGotD-
Jun 22, 2021
jmh530
Jun 22, 2021
mw
Jun 22, 2021
jmh530
Jun 22, 2021
mw
Jun 22, 2021
jmh530
Jun 22, 2021
mw
Jun 23, 2021
mw
Jun 23, 2021
12345swordy
Jun 22, 2021
mw
Jun 22, 2021
zjh
Jun 28, 2021
solidstate1991
Jun 28, 2021
12345swordy
Jun 28, 2021
Bruce Carneal
Jun 30, 2021
Alexandru Ermicioi
Jun 30, 2021
Alexandru Ermicioi
Jun 30, 2021
Alexandru Ermicioi
Jun 30, 2021
Alexandru Ermicioi
Jul 01, 2021
zjh
Jul 01, 2021
zjh
Jul 01, 2021
Alexandru Ermicioi
Jul 02, 2021
Jack Applegame
Jul 01, 2021
zjh
Jun 21, 2021
sighoya
Jun 21, 2021
Mathias LANG
Jun 22, 2021
Guillaume Piolat
June 21, 2021

What prevents unifying D classes with C++?

By that I mean: shouldn't it be possible to formulate an ABI for D classes that makes them fully C++ compatible?

Seems to me that D-interfaces can be implemented with C++ ABI for multiple inheritance for instance.

June 21, 2021

On Monday, 21 June 2021 at 13:40:42 UTC, Ola Fosheim Grøstad wrote:

>

What prevents unifying D classes with C++?

Multiple inheritance and Walter's strong opposition to said feature.

  • Alex
June 21, 2021

On Monday, 21 June 2021 at 13:40:42 UTC, Ola Fosheim Grøstad wrote:

>

What prevents unifying D classes with C++?

By that I mean: shouldn't it be possible to formulate an ABI for D classes that makes them fully C++ compatible?

+1 for that, never understood the reason against this given that we live in the 20ies now.
If performance is the problem, you wouldn't choose virtual dispatch anyway.
If safety is the problem, then disambiguation by scoping is the solution.

>

Seems to me that D-interfaces can be implemented with C++ ABI for multiple inheritance for instance.

Yes, but interfaces can't have fields. I find D should better interop with C++ classes without the extern sh!t, and supporting multiple inheritance should work out of the box.

Who wants to manually create thousands of classes to interop with a c++ framework?

June 21, 2021

On Monday, 21 June 2021 at 13:40:42 UTC, Ola Fosheim Grøstad wrote:

>

What prevents unifying D classes with C++?

By that I mean: shouldn't it be possible to formulate an ABI for D classes that makes them fully C++ compatible?

Seems to me that D-interfaces can be implemented with C++ ABI for multiple inheritance for instance.

The main reason they can't be ABI compatible is the TypeInfo AFAIR.
But extern(C++) does the job just fine.

June 21, 2021

On Monday, 21 June 2021 at 15:39:26 UTC, 12345swordy wrote:

>

On Monday, 21 June 2021 at 13:40:42 UTC, Ola Fosheim Grøstad wrote:

>

What prevents unifying D classes with C++?

Multiple inheritance and Walter's strong opposition to said feature.

  • Alex

I guarantee you that Walter is far from the only one here with strong opposition to multiple inheritance.

June 21, 2021

On Monday, 21 June 2021 at 17:55:25 UTC, Mathias LANG wrote:

>

The main reason they can't be ABI compatible is the TypeInfo AFAIR.
But extern(C++) does the job just fine.

Does this mean that you make all your classes extern(C++) ?

Can I define extern(C++) classes in D and instantiate them in D just fine and pass them to C++?

June 21, 2021

On Monday, 21 June 2021 at 19:56:50 UTC, Meta wrote:

>

I guarantee you that Walter is far from the only one here with strong opposition to multiple inheritance.

You are not affected by it if you don't use it, but D classes are very close to C++ so it is a bit silly to not unify. D classes don't provide significantly different semantics from C++ IMHO.

(Monitors can be viewed as a syntactical layer to some extent.)

June 21, 2021

On Monday, 21 June 2021 at 17:55:25 UTC, Mathias LANG wrote:

>

The main reason they can't be ABI compatible is the TypeInfo AFAIR.

Hm, but I think D could extend C++ type info?

I believe the C++ standard for runtime reflection will be extended though. Not sure what that implies for the ABI.

June 22, 2021

On Monday, 21 June 2021 at 19:56:50 UTC, Meta wrote:

>

On Monday, 21 June 2021 at 15:39:26 UTC, 12345swordy wrote:

multiple inheritance is very good.I dont know why they are objective.
10+ years ago,they refuse to listen others' suggestion.
I dont know if they still refuse now.

June 22, 2021

On Tuesday, 22 June 2021 at 02:13:33 UTC, zjh wrote:

>

multiple inheritance is very good.I dont know why they are objective.
10+ years ago,they refuse to listen others' suggestion.
I dont know if they still refuse now.

It's because the diamond problem. The diamond problem is purely an academic problem and it very seldom happens in the real world and if it does you probably did something wrong in your design. Happen to me once in 30 years because I messed up. Multiple inheritance is often flat, which means that one class inherits from several others at the same level. Instead of disallow multiple inheritance you can disallow the diamond pattern.

D went another way with composition with template mixins. Nothing particular wrong with this model but I think the D documentation isn't clear about its intended use. Also the overlap with alias this makes it more confusing.

« First   ‹ Prev
1 2 3 4 5