Jump to page: 1 25  
Page
Thread overview
C++ interop - what to do about long and unsigned long?
Sep 10, 2014
Walter Bright
Sep 10, 2014
bearophile
Sep 10, 2014
Walter Bright
Sep 10, 2014
bachmeier
Sep 10, 2014
Walter Bright
Sep 11, 2014
bachmeier
Sep 11, 2014
Paolo Invernizzi
Sep 11, 2014
Daniel Murphy
Sep 11, 2014
Paolo Invernizzi
Sep 12, 2014
Daniel Murphy
Sep 11, 2014
bachmeier
Sep 11, 2014
Sean Kelly
Sep 12, 2014
Andrej Mitrovic
Sep 11, 2014
Walter Bright
Sep 12, 2014
Manu
Sep 12, 2014
Daniel Murphy
Sep 13, 2014
Manu
Sep 13, 2014
Timon Gehr
Sep 13, 2014
Manu
Sep 13, 2014
Jacob Carlborg
Sep 13, 2014
bearophile
Sep 13, 2014
Walter Bright
Sep 14, 2014
Manu
Sep 14, 2014
Jakob Ovrum
Sep 14, 2014
David Nadlinger
Sep 14, 2014
monarch_dodra
Sep 12, 2014
bachmeier
Sep 10, 2014
Adam D. Ruppe
Sep 10, 2014
Adam D. Ruppe
Sep 11, 2014
Iain Buclaw
Sep 11, 2014
Daniel Murphy
Sep 11, 2014
monarch_dodra
Sep 11, 2014
Gary Willoughby
Sep 13, 2014
Daniel N
September 10, 2014
C++'s long and unsigned long can be accessed with c_long and c_ulong. Unfortunately, these are aliases and mangle to their underlying types.

Meaning that there is no way to interface to a C++ function declared as:

    void foo(unsigned long);

So, what to do about this?

1. elevate c_long and c_ulong into full fledged types.

2. create full fledged types __c_long and __c_ulong, and alias c_long and c_ulong to them.

3. some sort of attribute?

The same issue exists for C++'s 'long double'.
September 10, 2014
Walter Bright:

> 1. elevate c_long and c_ulong into full fledged types.

This looks like the simpler and cleaner solution. What are the disadvantages of this solution?

(In my opinion the C++ interop topic is way less important/urgent than designing and implementing the tracking/scoping of memory areas in D. So I am seeing a priority problem here).

Bye,
bearophile
September 10, 2014
On Wednesday, 10 September 2014 at 20:41:45 UTC, Walter Bright wrote:
> 2. create full fledged types __c_long and __c_ulong, and alias c_long and c_ulong to them.

That's what I'd do. Should have best compatibility too with other definitions of c_long in third party libs.
September 10, 2014
On 9/10/2014 2:08 PM, bearophile wrote:
> (In my opinion the C++ interop topic is way less important/urgent than designing
> and implementing the tracking/scoping of memory areas in D. So I am seeing a
> priority problem here).

Not inter-operating with C++ is turning out to be a huge barrier for D adoption.

September 10, 2014
"bearophile" <bearophileHUGS@lycos.com> wrote:
> Walter Bright:
> 
>> 1. elevate c_long and c_ulong into full fledged types.
> 
> This looks like the simpler and cleaner solution. What are the disadvantages of this solution?
> 
> (In my opinion the C++ interop topic is way less important/urgent than designing and implementing the tracking/scoping of memory areas in D. So I am seeing a priority problem here).
> 
> Bye,
> bearophile

C++ interoperability: 1,000,000 merit points
Anything related to the GC: 999,999 merit points
All else: two digits merit points
September 10, 2014
On Wednesday, 10 September 2014 at 21:08:30 UTC, bearophile wrote:
> (In my opinion the C++ interop topic is way less important/urgent than designing and implementing the tracking/scoping of memory areas in D. So I am seeing a priority problem here).

That would be nice, but C++ would be nicer. Not only does that really help in bringing D into existing code, it also makes things like using C++ libraries a lot easier. I'd enjoy access to Qt for example without needing 15 MB of wrapper code.
September 10, 2014
On Wednesday, 10 September 2014 at 21:32:22 UTC, Andrei Alexandrescu wrote:
> "bearophile" <bearophileHUGS@lycos.com> wrote:
>> Walter Bright:
>> 
>>> 1. elevate c_long and c_ulong into full fledged types.
>> 
>> This looks like the simpler and cleaner solution. What are the
>> disadvantages of this solution?
>> 
>> (In my opinion the C++ interop topic is way less important/urgent than
>> designing and implementing the tracking/scoping of memory areas in D. So
>> I am seeing a priority problem here).
>> 
>> Bye,
>> bearophile
>
> C++ interoperability: 1,000,000 merit points
> Anything related to the GC: 999,999 merit points
> All else: two digits merit points

Not to go too far off topic, but C++ interoperability is at 0 merit points until you've got a GC-less standard library, finished shared library support on all platforms, and tools that rival those available for C++.

Clearly Walter and everyone should work on whatever they think is important. I hope your statement doesn't imply that all development effort is going to be put into C++ compatibility.
September 10, 2014
On 9/10/2014 4:16 PM, bachmeier wrote:
> Not to go too far off topic, but C++ interoperability is at 0 merit points until
> you've got a GC-less standard library, finished shared library support on all
> platforms, and tools that rival those available for C++.

If that were true, then D interoperability with C would be impossible as well. But it is possible and works well.
September 11, 2014
On 9/10/14, 4:16 PM, bachmeier wrote:
> Not to go too far off topic, but C++ interoperability is at 0 merit
> points until you've got a GC-less standard library, finished shared
> library support on all platforms, and tools that rival those available
> for C++.

No. C++ interop and GC are related, but only loosely.

> Clearly Walter and everyone should work on whatever they think is
> important. I hope your statement doesn't imply that all development
> effort is going to be put into C++ compatibility.

Ideally it would.


Andrei

September 11, 2014
On Thursday, 11 September 2014 at 00:29:37 UTC, Andrei Alexandrescu wrote:
> On 9/10/14, 4:16 PM, bachmeier wrote:
>> Clearly Walter and everyone should work on whatever they think is
>> important. I hope your statement doesn't imply that all development
>> effort is going to be put into C++ compatibility.
>
> Ideally it would.
>
>
> Andrei

It's scaring that all the efforts are now focused on that.
I'm curious to understand the plan for interop with not-virtual class methods: OpenCV for example.
--
/Paolo


« First   ‹ Prev
1 2 3 4 5