Re: const(Class) is mangled as Class const* const

2017-03-28 Thread Walter Bright via Digitalmars-d
On 3/28/2017 11:12 AM, Jacob Carlborg wrote: As far as I understand, D can link with C++ templates if they're instantiated on the C++ side. It would link with the instantiated template not the actual template. Recall that dmd itself connected to C++ templates when the front end was not full i

Re: const(Class) is mangled as Class const* const

2017-03-28 Thread Jacob Carlborg via Digitalmars-d
On 2017-03-28 00:30, kinke wrote: Yep, so there are no libs my D code can link to, so how am I supposed to use C++ templates from D (as you're using that as argument for the `const T *const` mangling)? As far as I understand, D can link with C++ templates if they're instantiated on the C++ si

Re: const(Class) is mangled as Class const* const

2017-03-28 Thread kinke via Digitalmars-d
On Tuesday, 28 March 2017 at 14:11:16 UTC, deadalnix wrote: I understand you point and showed you why it isn't a mangling problem at all, and gave you direction you may want to dig in to make a proposal that may actually get traction. If you really did get my point, it should be clear that I d

Re: const(Class) is mangled as Class const* const

2017-03-28 Thread deadalnix via Digitalmars-d
On Tuesday, 28 March 2017 at 13:18:57 UTC, kinke wrote: You don't seem to get my point, I don't know why it's apparently that hard. It's hard because you assume I did not understood you point and you keep repeating the same thing. I understand you point and showed you why it isn't a mangling

Re: const(Class) is mangled as Class const* const

2017-03-28 Thread kinke via Digitalmars-d
On Tuesday, 28 March 2017 at 12:55:02 UTC, deadalnix wrote: On Tuesday, 28 March 2017 at 08:30:43 UTC, kinke wrote: What I don't get is why it's considered important to have a matching C++ mangling for templates across D and C++ - what for? I only care about mangling wrt. If you still think t

Re: const(Class) is mangled as Class const* const

2017-03-28 Thread deadalnix via Digitalmars-d
On Tuesday, 28 March 2017 at 08:30:43 UTC, kinke wrote: What I don't get is why it's considered important to have a matching C++ mangling for templates across D and C++ - what for? I only care about mangling wrt. If you still think this is a mangling problem, please reread my first response i

Re: const(Class) is mangled as Class const* const

2017-03-28 Thread kinke via Digitalmars-d
On Tuesday, 28 March 2017 at 02:14:25 UTC, Jonathan M Davis wrote: Realistically, unless D fully supports C++ (which pretty much means that it has to become C++ on some level), you're almost always going to be stuck with some sort of glue layer between D code and C++ code. There's no reasonable

Re: const(Class) is mangled as Class const* const

2017-03-27 Thread Jonathan M Davis via Digitalmars-d
On Monday, March 27, 2017 20:41:51 kinke via Digitalmars-d wrote: > On Monday, 27 March 2017 at 20:09:35 UTC, Walter Bright wrote: > > Whichever way it is mangled will gore someone's ox. D went with > > the simplest mangling solution, which is to mangle all C++ > > const pointers as "head const". >

Re: const(Class) is mangled as Class const* const

2017-03-27 Thread Walter Bright via Digitalmars-d
On 3/27/2017 3:30 PM, kinke wrote: On Monday, 27 March 2017 at 22:24:26 UTC, Walter Bright wrote: On 3/27/2017 3:12 PM, kinke wrote: It's made to work with: const T which is the norm with C++ templates. Okay, so how exactly do I bind D code to a C++ header-only-template library? I though

Re: const(Class) is mangled as Class const* const

2017-03-27 Thread kinke via Digitalmars-d
On Monday, 27 March 2017 at 22:24:26 UTC, Walter Bright wrote: On 3/27/2017 3:12 PM, kinke wrote: It's made to work with: const T which is the norm with C++ templates. Okay, so how exactly do I bind D code to a C++ header-only-template library? I thought that in that case you need a full

Re: const(Class) is mangled as Class const* const

2017-03-27 Thread Walter Bright via Digitalmars-d
On 3/27/2017 3:12 PM, kinke wrote: It's made to work with: const T which is the norm with C++ templates. Okay, so how exactly do I bind D code to a C++ header-only-template library? I thought that in that case you need a full D translation anyway... C++ templates are always header-only.

Re: const(Class) is mangled as Class const* const

2017-03-27 Thread kinke via Digitalmars-d
On Monday, 27 March 2017 at 22:04:55 UTC, Walter Bright wrote: On 3/27/2017 1:41 PM, kinke wrote: Unfortunately, it's almost always the other way around - D code trying to interop with one of the gazillions existing C++ libs, and nobody wants to maintain his own fork with D-compatible glue inte

Re: const(Class) is mangled as Class const* const

2017-03-27 Thread Walter Bright via Digitalmars-d
On 3/27/2017 1:41 PM, kinke wrote: Unfortunately, it's almost always the other way around - D code trying to interop with one of the gazillions existing C++ libs, and nobody wants to maintain his own fork with D-compatible glue interfaces. How often did you use `const T *const` vs. `const T *` in

Re: const(Class) is mangled as Class const* const

2017-03-27 Thread deadalnix via Digitalmars-d
On Sunday, 26 March 2017 at 22:56:59 UTC, Jerry wrote: On Sunday, 26 March 2017 at 22:29:56 UTC, deadalnix wrote: It is clear that you won't be able to express 100% of C++ in D, that would require to important all the weird parts of C++ into D, but if we are doing so, why use D in the first pla

Re: const(Class) is mangled as Class const* const

2017-03-27 Thread kinke via Digitalmars-d
On Monday, 27 March 2017 at 20:09:35 UTC, Walter Bright wrote: Whichever way it is mangled will gore someone's ox. D went with the simplest mangling solution, which is to mangle all C++ const pointers as "head const". [...] I suggest a simpler way - declare the C++ side of the D interface in a

Re: const(Class) is mangled as Class const* const

2017-03-27 Thread Walter Bright via Digitalmars-d
On 3/26/2017 3:29 PM, deadalnix wrote: Note that using const Class* in C++ is essentially useless. The class remains mutable and the reference is local the the callee anyway, so it doesn't change anything for the caller. Such a pattern is most likely indicative of a bug on the C++ side, or at lea

Re: const(Class) is mangled as Class const* const

2017-03-27 Thread Walter Bright via Digitalmars-d
On 3/26/2017 3:43 AM, Benjamin Thaut wrote: Should I open a bug for this? It's not a bug, it was intended that way. The trouble is that D cannot express a to . Whichever way it is mangled will gore someone's ox. D went with the simplest mangling solution, which is to mangle all C++ const po

Re: const(Class) is mangled as Class const* const

2017-03-27 Thread kinke via Digitalmars-d
On Sunday, 26 March 2017 at 17:41:57 UTC, Benjamin Thaut wrote: There are thousands of C++ libraries out there that can't be bound to D because they use const Class* instead of const Class* const. So in my eyes there is definitly something wrong with the C++ mangling of D. I agree that C++-ma

Re: const(Class) is mangled as Class const* const

2017-03-26 Thread Jonathan M Davis via Digitalmars-d
On Sunday, March 26, 2017 18:31:52 Jerry via Digitalmars-d wrote: > On Sunday, 26 March 2017 at 15:29:02 UTC, Jonathan M Davis wrote: > > Personally, I don't think that the fact that you can't use > > const for head-const in D is really a loss, since it's almost > > never what you want. Tail-const

Re: const(Class) is mangled as Class const* const

2017-03-26 Thread Jerry via Digitalmars-d
On Sunday, 26 March 2017 at 22:29:56 UTC, deadalnix wrote: It is clear that you won't be able to express 100% of C++ in D, that would require to important all the weird parts of C++ into D, but if we are doing so, why use D in the first place ? Note that using const Class* in C++ is essentiall

Re: const(Class) is mangled as Class const* const

2017-03-26 Thread deadalnix via Digitalmars-d
On Sunday, 26 March 2017 at 17:41:57 UTC, Benjamin Thaut wrote: On Sunday, 26 March 2017 at 14:30:00 UTC, deadalnix wrote: It's consistent. D's const is transitive, and D doesn't allow you to specify const on the indirection of a reference type. So there is no problem on the C++ mangling side

Re: const(Class) is mangled as Class const* const

2017-03-26 Thread Jerry via Digitalmars-d
On Sunday, 26 March 2017 at 15:29:02 UTC, Jonathan M Davis wrote: Personally, I don't think that the fact that you can't use const for head-const in D is really a loss, since it's almost never what you want. Tail-const is _way_ more useful. But it is true that by making D's const fully transiti

Re: const(Class) is mangled as Class const* const

2017-03-26 Thread Benjamin Thaut via Digitalmars-d
On Sunday, 26 March 2017 at 14:30:00 UTC, deadalnix wrote: It's consistent. D's const is transitive, and D doesn't allow you to specify const on the indirection of a reference type. So there is no problem on the C++ mangling side of things, but, arguably, there is one in D's sementic, that is

Re: const(Class) is mangled as Class const* const

2017-03-26 Thread Jonathan M Davis via Digitalmars-d
On Sunday, March 26, 2017 14:51:28 Namespace via Digitalmars-d wrote: > On Sunday, 26 March 2017 at 14:30:00 UTC, deadalnix wrote: > > On Sunday, 26 March 2017 at 10:43:11 UTC, Benjamin Thaut wrote: > >> As you see from the above example D mangles the getClassConst > >> as a "Class const * const" i

Re: const(Class) is mangled as Class const* const

2017-03-26 Thread Namespace via Digitalmars-d
On Sunday, 26 March 2017 at 14:30:00 UTC, deadalnix wrote: On Sunday, 26 March 2017 at 10:43:11 UTC, Benjamin Thaut wrote: As you see from the above example D mangles the getClassConst as a "Class const * const" instead of a "Class const *" ("YAQEBV" vs "YAPEBV"). Is this expected behavior? I

Re: const(Class) is mangled as Class const* const

2017-03-26 Thread deadalnix via Digitalmars-d
On Sunday, 26 March 2017 at 10:43:11 UTC, Benjamin Thaut wrote: As you see from the above example D mangles the getClassConst as a "Class const * const" instead of a "Class const *" ("YAQEBV" vs "YAPEBV"). Is this expected behavior? It's consistent. D's const is transitive, and D doesn't allow

const(Class) is mangled as Class const* const

2017-03-26 Thread Benjamin Thaut via Digitalmars-d
Consider the following C++ and D source: class Class { virtual ~Class(){} }; // mangles as ?getClass@@YAPEAVClass@@XZ Class * getClass() { return nullptr; } // mangles as ?getClassConst@@YAPEBVClass@@XZ const Class * getClassConst() { return nullptr; } // mangles as ?getClassConstConst