digitalmars.D.announce - DMD 1.022 and 2.005 releases
- Walter Bright (7/7) Oct 05 2007 Bug fixes. New (and very modest) C++ interface. Library module overhauls...
- renoX (5/14) Oct 05 2007 Nice touch for adding write and writeln to std.stdio: naming consistency...
- Sean Kelly (8/11) Oct 05 2007 And to think I just patched some code and makefiles last night to work
- Sean Kelly (8/21) Oct 11 2007 So it took me a bit longer than expected to get to this. Things were
- Jascha Wetzel (5/14) Oct 05 2007 neat!
- Craig Black (4/18) Oct 07 2007 I don't think MSVC will work. Only DMC. Or am I wrong?
- Walter Bright (3/11) Oct 07 2007 It does follow MSVC's name mangling scheme and function interface. It
- Aarti_pl (14/26) Oct 07 2007 I just wonder if it wouldn't be better to allow external plugins for
- Aarti_pl (7/23) Oct 08 2007 BTW: Word plugins is used in 2.0 changelog, when mentioning about C++
- Walter Bright (4/16) Oct 08 2007 I think the number of different calling conventions in use is pretty
- Aarti_pl (15/35) Oct 08 2007 Real advantage would be that someone (some company?) could implement
- Bruce Adams (5/24) Oct 08 2007 I was going to post a similar question. I do most of my development via ...
- BCS (2/9) Oct 08 2007 I would not be a bit surprised if DMD linux does uses GCC naming right n...
- Walter Bright (2/3) Oct 08 2007 It does :-)
- Walter Bright (4/10) Oct 08 2007 Supporting gcc name mangling isn't enough, as dmd on Windows doesn't
- Frits van Bommel (10/21) Oct 08 2007 Correct me if I'm wrong, but if mangling was taken care of such code
- Walter Bright (7/31) Oct 08 2007 There's a lot more to binary compatibility than name mangling. Matching
- Bruce Adams (8/43) Oct 08 2007 I try but you never know how portable your code really isn't until you t...
- Walter Bright (6/28) Oct 08 2007 Right. But such is worth doing once in a while, because afterwards one
- BCS (8/17) Oct 05 2007 C++, coool.
- Walter Bright (6/14) Oct 05 2007 Don't know what you mean.
- BCS (18/29) Oct 05 2007 will this work?
- Walter Bright (7/36) Oct 05 2007 Yes.
- Stewart Gordon (16/23) Oct 05 2007 I've noticed a few things about cpp_interface.html:
-
Stewart Gordon
(14/16)
Oct 06 2007
"Stewart Gordon"
wrote in message - Frits van Bommel (8/19) Oct 06 2007 With printf() it probably just works because it uses C-style varargs and...
-
Stewart Gordon
(11/15)
Oct 06 2007
"Frits van Bommel"
wrote in message - Frits van Bommel (10/23) Oct 07 2007 I'm not sure if that's part of the actual spec. If conformance to that
- Bill Baxter (4/13) Oct 05 2007 Do Andrei and Brad have access to your code repository now? If so --
- Walter Bright (5/7) Oct 05 2007 Yes. We've been working together for a long time, now. Andrei brings a
- Derek Parnell (6/14) Oct 05 2007 Now that is a Bright idea. Kudos to all involved.
- Stewart Gordon (7/14) Oct 06 2007 I see. Do they have access to the documentation repository as well?
- Walter Bright (2/3) Oct 06 2007 That came up and is a good idea, it just hasn't been done yet.
- nazo (3/12) Oct 06 2007 great!
- Robert Fraser (2/97) Oct 06 2007 Awesome. Just... awesome.
- BCS (4/12) Oct 06 2007 Now, would anyone be interested in making a dtoh program? (Find all exte...
- Extrawurst (4/11) Oct 06 2007 Thanks Walter. Good work.
- janderson (3/12) Oct 06 2007 Neat with the C++ linkage stuff. Now all I have to figure out
- Paul Findlay (6/9) Oct 06 2007 This is all very good :)
- Walter Bright (4/14) Oct 06 2007 The C++ interface only extends to the calling convention, name mangling,...
- Bruce Adams (4/16) Oct 08 2007 I doubt it is that practical. Though perhaps worth a try. gcc its well i...
- Walter Bright (3/19) Oct 08 2007 When gdc folds this in, then gdc/g++ should also work. I don't know what...
- Bruce Adams (3/23) Oct 08 2007 I started out trying to use gdc/cygwin and gave up. The general advice I...
- Walter Bright (4/12) Oct 08 2007 I agree that running into compiler bugs always sucks, but please be sure...
- Don Clugston (4/13) Oct 09 2007 Thanks, Walter. Especially for bug fixes 1488 and 1125.
- Walter Bright (4/7) Oct 09 2007 It's a bit of a shot in the dark. I'm very curious to see how it will
- janderson (5/15) Oct 09 2007 I think once this feature matures, another article highlighting the
- Walter Bright (3/20) Oct 09 2007 Another angle is that *no other language* provides any sort of hook into...
- James Dennett (7/28) Oct 09 2007 Felix does (and has been around for roughly as long as D). It was
- Brad Roberts (3/29) Oct 09 2007 It's my understanding that C# does as well, but I don't have any direct
- KlausO (10/13) Oct 09 2007 C# does not connect to C++ directly (via name mangling). You can invoke
- Walter Bright (5/15) Oct 10 2007 D has had support for COM from day 1. But D's new support for C++ goes
- Walter Bright (2/11) Oct 09 2007 I'd never heard of Felix :-)
- BLS (4/16) Oct 10 2007 Regarding C++ interop. :
- BLS (22/31) Oct 09 2007 The C++ interface is IMO completely useless . Let me quote Walter
- Jarrett Billingsley (4/7) Oct 09 2007 Wow, harsh. There are those of us who don't actually spend all of our t...
- Walter Bright (5/14) Oct 09 2007 I don't recommend anyone actually translate C++ code to D, or C code for...
- Bill Baxter (14/31) Oct 09 2007 While that sounds like good advice in general, if the C++ library in
- Walter Bright (4/18) Oct 09 2007 I'll agree (from much personal experience) that translating code is a
- BLS (5/16) Oct 10 2007 Yes sure. But in case that you want, respective need to translate, a few...
- 0ffh (3/6) Oct 10 2007 Nope, actually, I don't. If you're so in love with C++, why bother with ...
- BLS (7/15) Oct 10 2007 NOOOOOoooo, clarification ;-), I don't like C++, BUT I need to translate...
- 0ffh (11/21) Oct 10 2007 What is an SL?
- BLS (25/56) Oct 10 2007 I am pretty sure Gerhard Schroeder still has a top ten placement on
- 0ffh (5/14) Oct 10 2007 With the help of explicit pointers and dereferencing, I can see no troub...
- BLS (5/11) Oct 10 2007 Would be nice if you are willing to offer an example.
- Bill Baxter (5/19) Oct 10 2007 He just means have the function return Foo* instead of Foo&. And then
- BLS (4/25) Oct 10 2007 Thanks for clarification Bill. Wonder why Frank wrote : "except you'll
- Regan Heath (21/47) Oct 10 2007 I assumed he meant something like:
- BLS (6/61) Oct 10 2007 I think :
- Regan Heath (3/7) Oct 10 2007 I know that, I was just guessing what 0ffh (aka Frank) was referring to.
- BLS (7/16) Oct 10 2007 The problem is ;
- Bill Baxter (6/53) Oct 10 2007 Except if you try to call foo(42).
- 0ffh (50/54) Oct 10 2007 Okay, I am more a C type of person not C++, so I hope
Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zip
Oct 05 2007
Walter Bright a écrit :Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zipNice touch for adding write and writeln to std.stdio: naming consistency is important indeed. Thanks, renoX
Oct 05 2007
Walter Bright wrote:Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized.And to think I just patched some code and makefiles last night to work around some of these bugs :-) Nice work! On a semi-related note, a Tango release is planned for today. In fact, it's already packaged and ready to go. So I'll give DMD 1.022 support a look this evening and perhaps we'll re-release tomorrow if any changes are necessary. I have jury duty so I won't be able to get to it today. Sean
Oct 05 2007
Sean Kelly wrote:Walter Bright wrote:So it took me a bit longer than expected to get to this. Things were also a bit complicated by the fact the the timestamps for most of the files had changed even though the files themselves were untouched. Fortunately, my diff tool was up to the task, and it seems there are no runtime changes necessary for Tango in this release. I love it when that happens :-) SeanBug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized.And to think I just patched some code and makefiles last night to work around some of these bugs :-) Nice work! On a semi-related note, a Tango release is planned for today. In fact, it's already packaged and ready to go. So I'll give DMD 1.022 support a look this evening and perhaps we'll re-release tomorrow if any changes are necessary. I have jury duty so I won't be able to get to it today.
Oct 11 2007
Walter Bright wrote:Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zipneat! maybe the docs for c++ interfacing should mention, that it requires a compatible c++ compiler to work (DMC or MSVC on windows and GCC 3.x on linux?).
Oct 05 2007
"Jascha Wetzel" <firstname mainia.de> wrote in message news:fe63ji$10r2$1 digitalmars.com...Walter Bright wrote:I don't think MSVC will work. Only DMC. Or am I wrong? -CraigBug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zipneat! maybe the docs for c++ interfacing should mention, that it requires a compatible c++ compiler to work (DMC or MSVC on windows and GCC 3.x on linux?).
Oct 07 2007
Craig Black wrote:"Jascha Wetzel" <firstname mainia.de> wrote in message news:fe63ji$10r2$1 digitalmars.com...It does follow MSVC's name mangling scheme and function interface. It should work with MSVC compile C++ DLLs.maybe the docs for c++ interfacing should mention, that it requires a compatible c++ compiler to work (DMC or MSVC on windows and GCC 3.x on linux?).I don't think MSVC will work. Only DMC. Or am I wrong?
Oct 07 2007
Walter Bright pisze:Craig Black wrote:I just wonder if it wouldn't be better to allow external plugins for DMD. This way you could just create different plugins to allow different name mangling and different interpretation of data in extern() sections... We could have then different plugins written by external vendors eg: CPP_GCC CPP_MSVC Pascal etc. Walter, did you think about solution like this? Is there possibility to implement this? Regards Marcin Kuszczak (aarti_pl)"Jascha Wetzel" <firstname mainia.de> wrote in message news:fe63ji$10r2$1 digitalmars.com...It does follow MSVC's name mangling scheme and function interface. It should work with MSVC compile C++ DLLs.maybe the docs for c++ interfacing should mention, that it requires a compatible c++ compiler to work (DMC or MSVC on windows and GCC 3.x on linux?).I don't think MSVC will work. Only DMC. Or am I wrong?
Oct 07 2007
Aarti_pl pisze:I just wonder if it wouldn't be better to allow external plugins for DMD. This way you could just create different plugins to allow different name mangling and different interpretation of data in extern() sections... We could have then different plugins written by external vendors eg: CPP_GCC CPP_MSVC Pascal etc. Walter, did you think about solution like this? Is there possibility to implement this? Regards Marcin Kuszczak (aarti_pl)BTW: Word plugins is used in 2.0 changelog, when mentioning about C++ interface, but *probably* in other meaning... It would be nice to see real plugins for D compiler... BR Marcin Kuszczak (aarti_pl)
Oct 08 2007
Aarti_pl wrote:I just wonder if it wouldn't be better to allow external plugins for DMD. This way you could just create different plugins to allow different name mangling and different interpretation of data in extern() sections... We could have then different plugins written by external vendors eg: CPP_GCC CPP_MSVC Pascal etc. Walter, did you think about solution like this?No.Is there possibility to implement this?I think the number of different calling conventions in use is pretty limited, so the benefit may not be there.
Oct 08 2007
Walter Bright pisze:Aarti_pl wrote:Real advantage would be that someone (some company?) could implement everything necessary to easily link D with C++ (you wrote that it needs 10 man-years, so I prefer you won't do it :D ). Also it would allow to prepare plugins for other languages, without bloating D compiler itself. Maybe it would be even commercial C++ plugin. But I guess that for companies which want to start working with D and connect new D code with old C++ code, price will be no-issue. It is possible that also some other functionality of compiler could be delegated to plugins, but currently I have in mind only this extern() thing... BR Marcin Kuszczak (Aarti_pl)I just wonder if it wouldn't be better to allow external plugins for DMD. This way you could just create different plugins to allow different name mangling and different interpretation of data in extern() sections... We could have then different plugins written by external vendors eg: CPP_GCC CPP_MSVC Pascal etc. Walter, did you think about solution like this?No.Is there possibility to implement this?I think the number of different calling conventions in use is pretty limited, so the benefit may not be there.
Oct 08 2007
Walter Bright Wrote:Aarti_pl wrote:I was going to post a similar question. I do most of my development via gcc. I'm only using DMD on windows rather than gdc because its more reliable (relative to the current state of gdc on cygwin). I have a lot of current C++ code working under gcc which is one thing holding me back from adopting D wholesale. A way of supporting gcc style name mangling as opposed to M$ would be very useful. Regards, Bruce.I just wonder if it wouldn't be better to allow external plugins for DMD. This way you could just create different plugins to allow different name mangling and different interpretation of data in extern() sections... We could have then different plugins written by external vendors eg: CPP_GCC CPP_MSVC Pascal etc. Walter, did you think about solution like this?No.Is there possibility to implement this?I think the number of different calling conventions in use is pretty limited, so the benefit may not be there.
Oct 08 2007
Bruce Adams wrote:I was going to post a similar question. I do most of my development via gcc. I'm only using DMD on windows rather than gdc because its more reliable (relative to the current state of gdc on cygwin). I have a lot of current C++ code working under gcc which is one thing holding me back from adopting D wholesale. A way of supporting gcc style name mangling as opposed to M$ would be very useful. Regards, Bruce.I would not be a bit surprised if DMD linux does uses GCC naming right now.
Oct 08 2007
BCS wrote:I would not be a bit surprised if DMD linux does uses GCC naming right now.It does :-)
Oct 08 2007
Bruce Adams wrote:I was going to post a similar question. I do most of my development via gcc. I'm only using DMD on windows rather than gdc because its more reliable (relative to the current state of gdc on cygwin). I have a lot of current C++ code working under gcc which is one thing holding me back from adopting D wholesale. A way of supporting gcc style name mangling as opposed to M$ would be very useful.Supporting gcc name mangling isn't enough, as dmd on Windows doesn't generate ELF and is incompatible with gcc on many levels. A more practical approach is to recompile your C++ source using DMC++.
Oct 08 2007
Walter Bright wrote:Bruce Adams wrote:Correct me if I'm wrong, but if mangling was taken care of such code could still be linked if for example the C++ code was in a DLL, right? Or is the C++ parameter & result passing of mingw/cygwin g++ so different from any method supported by DMD? (IIRC on Linux it's basically the C calling convention with an implicit first 'this' argument for member functions and s/&/*/ on all types)I was going to post a similar question. I do most of my development via gcc. I'm only using DMD on windows rather than gdc because its more reliable (relative to the current state of gdc on cygwin). I have a lot of current C++ code working under gcc which is one thing holding me back from adopting D wholesale. A way of supporting gcc style name mangling as opposed to M$ would be very useful.Supporting gcc name mangling isn't enough, as dmd on Windows doesn't generate ELF and is incompatible with gcc on many levels.A more practical approach is to recompile your C++ source using DMC++.That would depend on how much of it there is to recompile, wouldn't it? :P (Also, the code may use GNU extensions to C++ not present in DMC, requiring more work to port than a simple recompile)
Oct 08 2007
Frits van Bommel wrote:Walter Bright wrote:There's a lot more to binary compatibility than name mangling. Matching the names in a DLL is only the start.Bruce Adams wrote:Correct me if I'm wrong, but if mangling was taken care of such code could still be linked if for example the C++ code was in a DLL, right? Or is the C++ parameter & result passing of mingw/cygwin g++ so different from any method supported by DMD?I was going to post a similar question. I do most of my development via gcc. I'm only using DMD on windows rather than gdc because its more reliable (relative to the current state of gdc on cygwin). I have a lot of current C++ code working under gcc which is one thing holding me back from adopting D wholesale. A way of supporting gcc style name mangling as opposed to M$ would be very useful.Supporting gcc name mangling isn't enough, as dmd on Windows doesn't generate ELF and is incompatible with gcc on many levels.(IIRC on Linux it's basically the C calling convention with an implicit first 'this' argument for member functions and s/&/*/ on all types)It depends on how portably the C++ code is written, not on how much there is.A more practical approach is to recompile your C++ source using DMC++.That would depend on how much of it there is to recompile, wouldn't it? :P(Also, the code may use GNU extensions to C++ not present in DMC, requiring more work to port than a simple recompile)My experiences with non-standard extensions is there's almost never a good reason to use them, and this issue is yet another good reason not to.
Oct 08 2007
Walter Bright Wrote:Frits van Bommel wrote:I try but you never know how portable your code really isn't until you try a different platform/compiler for the first time. They all have their horrid little quirks mostly because of the preprocessor that D gets rid of. (Then of course anything in M$ land takes the book and throws it out the window they then write a new book and call it gospel.) Another problem comes when you have third party libraries in use. As a user of gcc I naturally have made use of a number of linux type, autoconf configure, make based libraries. I can be confident they will work with gcc but not necessarily with anything else (especially as they tend to written in old fashioned C). I don't want to port them as well.Walter Bright wrote:There's a lot more to binary compatibility than name mangling. Matching the names in a DLL is only the start.Bruce Adams wrote:Correct me if I'm wrong, but if mangling was taken care of such code could still be linked if for example the C++ code was in a DLL, right? Or is the C++ parameter & result passing of mingw/cygwin g++ so different from any method supported by DMD?I was going to post a similar question. I do most of my development via gcc. I'm only using DMD on windows rather than gdc because its more reliable (relative to the current state of gdc on cygwin). I have a lot of current C++ code working under gcc which is one thing holding me back from adopting D wholesale. A way of supporting gcc style name mangling as opposed to M$ would be very useful.Supporting gcc name mangling isn't enough, as dmd on Windows doesn't generate ELF and is incompatible with gcc on many levels.(IIRC on Linux it's basically the C calling convention with an implicit first 'this' argument for member functions and s/&/*/ on all types)It depends on how portably the C++ code is written, not on how much there is.A more practical approach is to recompile your C++ source using DMC++.That would depend on how much of it there is to recompile, wouldn't it? :PIn general yes. But there are a few exceptions to prove the rule. One is access to the stack frame (e.g. for creating stack traces that customers can send back). This is one I actually use but only in one module. It was painful at the time and no doubt it is equally painful every time on each new (or in my case not gnu) compiler. There may be other nasty little tricksy things them 'obbits' is keeping from us. Bruce.(Also, the code may use GNU extensions to C++ not present in DMC, requiring more work to port than a simple recompile)My experiences with non-standard extensions is there's almost never a good reason to use them, and this issue is yet another good reason not to.
Oct 08 2007
Bruce Adams wrote:Walter Bright Wrote:Right. But such is worth doing once in a while, because afterwards one tends to implicitly avoid non-portable constructs.It depends on how portably the C++ code is written, not on how much there is.I try but you never know how portable your code really isn't until you try a different platform/compiler for the first time.Another problem comes when you have third party libraries in use. As a user of gcc I naturally have made use of a number of linux type, autoconf configure, make based libraries. I can be confident they will work with gcc but not necessarily with anything else (especially as they tend to written in old fashioned C). I don't want to port them as well.I agree that would be a serious impediment.Stack frame layouts might be comparable enough that you can port that bit of code.My experiences with non-standard extensions is there's almost never a good reason to use them, and this issue is yet another good reason not to.In general yes. But there are a few exceptions to prove the rule. One is access to the stack frame (e.g. for creating stack traces that customers can send back). This is one I actually use but only in one module. It was painful at the time and no doubt it is equally painful every time on each new (or in my case not gnu) compiler. There may be other nasty little tricksy things them 'obbits' is keeping from us.
Oct 08 2007
Walter Bright wrote:Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zipC++, coool. --Typo from http://www.digitalmars.com/d/cpp_interface.html Use the limited ability described here to connect directly to C functions and classes. that should be c++ functions and classes. --To what extent does overloading work across C++/D? --Is dmc going to get an "extern(D)" extension?
Oct 05 2007
BCS wrote:--Typo from http://www.digitalmars.com/d/cpp_interface.html Use the limited ability described here to connect directly to C functions and classes. that should be c++ functions and classes.Got it.--To what extent does overloading work across C++/D?Don't know what you mean.--Is dmc going to get an "extern(D)" extension?No. My experience with C++ extensions is that people won't use them, so they're a waste of time. There are other problems, too, like C++ has no notion of a module, so where's the D module name going to come from?
Oct 05 2007
Walter Bright wrote:BCS wrote:will this work? extern(c++) { int Foo(int i); int Foo(int* ip); } void bar() { int i; Foo(i); Foo(&i); } What about if there is a void Foo(int[] ia){...} // non extern(c++) Will that overload with the c++ functions? Can D define overloaded extern(c++) function for C++ to link with?--To what extent does overloading work across C++/D?Don't know what you mean.Shucks.--Is dmc going to get an "extern(D)" extension?No.
Oct 05 2007
BCS wrote:Walter Bright wrote:Use a capital C.BCS wrote:will this work? extern(c++)--To what extent does overloading work across C++/D?Don't know what you mean.{ int Foo(int i); int Foo(int* ip); } void bar() { int i; Foo(i); Foo(&i); }Yes.What about if there is a void Foo(int[] ia){...} // non extern(c++) Will that overload with the c++ functions?Yes. Just remember that the selection of function will follow D overloading rules, not C++ rules, even if the functions are labeled extern(C++).Can D define overloaded extern(c++) function for C++ to link with?Yes.
Oct 05 2007
"Walter Bright" <newshound1 digitalmars.com> wrote in message news:fe5vv7$s07$1 digitalmars.com...Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zipI've noticed a few things about cpp_interface.html: 1. `Strings are not 0 terminated in D. See "Data Type Compatibility" for more information about this. However, string literals in D are 0 terminated.` However, there's nothing specific about strings in the referenced section. 2. In Data Type Compatibility: no equivalent type & Is ref type not the D equivalent of this? 3. How about making it so that D dynamic array parameters become, on the C++ side, two parameters: length and pointer? Stewart. -- My e-mail address is valid but not my primary mailbox. Please keep replies on the 'group where everybody may benefit.
Oct 05 2007
"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:fe6f68$1gm8$1 digitalmars.com... <snip>3. How about making it so that D dynamic array parameters become, on the C++ side, two parameters: length and pointer?I've just been thinking a bit more about this. I guess it's just a matter of name mangling - I haven't checked, but it would appear from the old printf-on-strings issue that pushing two arguments in succession is equivalent to pushing the concatenation of (the memory representations of) them in one go. (Is this platform dependent?) It's safer in C++ than in C, because if the writer of the C++ code misremembers which way round they go, the mangled names won't match. Stewart. -- My e-mail address is valid but not my primary mailbox. Please keep replies on the 'group where everybody may benefit.
Oct 06 2007
Stewart Gordon wrote:"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:fe6f68$1gm8$1 digitalmars.com... <snip>With printf() it probably just works because it uses C-style varargs and the two elements of a char[] happen to both be the "native" size of the processor (so there's no padding inserted). It may not even work on all platforms. Also, AFAIK the compiler would be well within its rights to use the opposite order of .length and .ptr in memory; meaning that even if the C calling convention allows this the order they're passed in isn't guaranteed.3. How about making it so that D dynamic array parameters become, on the C++ side, two parameters: length and pointer?I've just been thinking a bit more about this. I guess it's just a matter of name mangling - I haven't checked, but it would appear from the old printf-on-strings issue that pushing two arguments in succession is equivalent to pushing the concatenation of (the memory representations of) them in one go. (Is this platform dependent?)
Oct 06 2007
"Frits van Bommel" <fvbommel REMwOVExCAPSs.nl> wrote in message news:fe995o$3de$1 digitalmars.com... <snip>Also, AFAIK the compiler would be well within its rights to use the opposite order of .length and .ptr in memory; meaning that even if the C calling convention allows this the order they're passed in isn't guaranteed.Not according to http://www.digitalmars.com/d/abi.html But one thing that might affect whether it works is if, on a given system, the memory layout of the stack goes the other way or is even non-linear. Stewart. -- My e-mail address is valid but not my primary mailbox. Please keep replies on the 'group where everybody may benefit.
Oct 06 2007
Stewart Gordon wrote:"Frits van Bommel" <fvbommel REMwOVExCAPSs.nl> wrote in message news:fe995o$3de$1 digitalmars.com... <snip>I'm not sure if that's part of the actual spec. If conformance to that ABI is required to be an implementation of D then only DMD qualifies, and non-x86 D compilers are impossible (since the ABI is x86-specific)... And from that page: "A D implementation that conforms to the D ABI (Application Binary Interface) will be able to [...]" which I read to imply there can also be D implementations that _don't_ conform to that ABI. (such as GDC, and probably the compilers currently in production (LLVM, dil) as well as any compiler that supports non-x86 target systems)Also, AFAIK the compiler would be well within its rights to use the opposite order of .length and .ptr in memory; meaning that even if the C calling convention allows this the order they're passed in isn't guaranteed.Not according to http://www.digitalmars.com/d/abi.htmlBut one thing that might affect whether it works is if, on a given system, the memory layout of the stack goes the other way or is even non-linear.Certainly. But such a system wouldn't be an x86, so see above.
Oct 07 2007
Walter Bright wrote:Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zipDo Andrei and Brad have access to your code repository now? If so -- that's great news! --bb
Oct 05 2007
Bill Baxter wrote:Do Andrei and Brad have access to your code repository now? If so -- that's great news!Yes. We've been working together for a long time, now. Andrei brings a fountain of new ideas and cutting edge technology, and Brad has a knack for applying organization and process to chaos. I think it'll work much better than my cowboy approach <g>.
Oct 05 2007
On Fri, 05 Oct 2007 18:23:16 -0700, Walter Bright wrote:Bill Baxter wrote:Now that is a Bright idea. Kudos to all involved. -- Derek Parnell Melbourne, Australia skype: derek.j.parnellDo Andrei and Brad have access to your code repository now? If so -- that's great news!Yes. We've been working together for a long time, now. Andrei brings a fountain of new ideas and cutting edge technology, and Brad has a knack for applying organization and process to chaos. I think it'll work much better than my cowboy approach <g>.
Oct 05 2007
"Walter Bright" <newshound1 digitalmars.com> wrote in message news:fe6o19$1qv2$1 digitalmars.com...Bill Baxter wrote:I see. Do they have access to the documentation repository as well? Stewart. -- My e-mail address is valid but not my primary mailbox. Please keep replies on the 'group where everybody may benefit.Do Andrei and Brad have access to your code repository now? If so -- that's great news!Yes. We've been working together for a long time, now. Andrei brings a fountain of new ideas and cutting edge technology, and Brad has a knack for applying organization and process to chaos. I think it'll work much better than my cowboy approach <g>.
Oct 06 2007
Stewart Gordon wrote:I see. Do they have access to the documentation repository as well?That came up and is a good idea, it just hasn't been done yet.
Oct 06 2007
Walter Bright wrote:Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zipgreat! I wrote "C++ constructor/destructor" template for g++ and it works fine!
Oct 06 2007
nazo Wrote:Walter Bright wrote:Awesome. Just... awesome.Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zipgreat! I wrote "C++ constructor/destructor" template for g++ and it works fine! #include <iostream> using namespace std; class D{ public: D(); ~D(); virtual int bar(int i, int j, int k); }; D::D(){ printf("start\n"); } D::~D(){ printf("end\n"); } int D::bar(int i, int j, int k){ cout << "i = " << i << endl; cout << "j = " << j << endl; cout << "k = " << k << endl; return 8; }; import std.metastrings; extern (C++){ interface D{ int bar(int i, int j, int k); } } extern(C){ void* _Znwj(uint); void _ZdlPv(void*); } template cpp_decl(T){ const cpp_decl = "extern(C) extern char* _ZTV"~ToString!(T.stringof.length)~T.stringof~";"; } template cpp_constructor(T, ARGS...){ const cpp_constructor = "extern(C) void _ZN"~ToString!(T.stringof.length)~T.stringof~"C1Ev(void*);";//fixme: mangle and type } template cpp_destructor(T){ const cpp_destructor = "extern(C) void _ZN"~ToString!(T.stringof.length)~T.stringof~"D1Ev(void*);"; } T cpp_new(T, ARGS...)(ARGS args){ const fn="_ZN"~ToString!(T.stringof.length)~T.stringof~"C1Ev";//fixme: mangle void* rv; rv = _Znwj(T.sizeof); static if(is(typeof(mixin(fn)))){ mixin("alias "~fn~" init;"); init(rv, args); }else static if(ARGS.length==0){ *cast(void**)rv = mixin("&_ZTV"~ToString!(T.stringof.length)~T.stringof)+2; }else static assert(0); return cast(D)rv; } void cpp_delete(T)(T obj){ const fn="_ZN"~ToString!(T.stringof.length)~T.stringof~"D1Ev"; static if(is(typeof(mixin(fn)))){ mixin("alias "~fn~" term;"); term(cast(void*)obj); } _ZdlPv(cast(void*)obj); } mixin(cpp_decl!(D)); mixin(cpp_constructor!(D));//if D has constructor mixin(cpp_destructor!(D));//if D has destructor void main(){ D d = cpp_new!(D); d.bar(9,10,11); cpp_delete(d); }
Oct 06 2007
Reply to Walter,Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zipNow, would anyone be interested in making a dtoh program? (Find all extern c/c++ declaration and make a .h file for them). The name could be shortened to "d'oh".
Oct 06 2007
Thanks Walter. Good work. I can finally build my Code with optimizations again, yeeeehaa. --Extrawurst Walter Bright schrieb:Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zip
Oct 06 2007
Walter Bright wrote:Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zipNeat with the C++ linkage stuff. Now all I have to figure out appropriate places to incorporate D into my C++ projects :)
Oct 06 2007
Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized.This is all very good :) With C++ interfaces, is D able to do anything similar to "all functions that are not overridden can be optimized to be non-virtual"? And is the lack of support for static and non-virtual members because it is infeasible or in-expressible? Â - Paul
Oct 06 2007
Paul Findlay wrote:The C++ interface only extends to the calling convention, name mangling, and vtbl[] layout. No other C++ rules are followed.Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized.This is all very good :) With C++ interfaces, is D able to do anything similar to "all functions that are not overridden can be optimized to be non-virtual"?And is the lack of support for static and non-virtual members because it is infeasible or in-expressible?I thought we'd see how far we get with this first.
Oct 06 2007
Walter Bright Wrote:Bruce Adams wrote:I doubt it is that practical. Though perhaps worth a try. gcc its well integrated with my build system and I keep my code portable between windows and linux. It sounds like I'm out of luck there :(. It was hard enough to persuade myself to try dmd when gdc didn't work for me. I know gcc's interface backwards. Jumping to another vendor (even you :-) is just a little step too far for me. Not to mention having to swap gdb for ddbg or whatever it is. I might try porting something simple as an exercise in improving the portability of some code just to see what happens. As Captain Oates said, I may be some time... Bruce.I was going to post a similar question. I do most of my development via gcc. I'm only using DMD on windows rather than gdc because its more reliable (relative to the current state of gdc on cygwin). I have a lot of current C++ code working under gcc which is one thing holding me back from adopting D wholesale. A way of supporting gcc style name mangling as opposed to M$ would be very useful.Supporting gcc name mangling isn't enough, as dmd on Windows doesn't generate ELF and is incompatible with gcc on many levels. A more practical approach is to recompile your C++ source using DMC++.
Oct 08 2007
Bruce Adams wrote:Walter Bright Wrote:When gdc folds this in, then gdc/g++ should also work. I don't know what other issues there are with gdc.A more practical approach is to recompile your C++ source using DMC++.I doubt it is that practical. Though perhaps worth a try. gcc its well integrated with my build system and I keep my code portable between windows and linux. It sounds like I'm out of luck there :(. It was hard enough to persuade myself to try dmd when gdc didn't work for me. I know gcc's interface backwards. Jumping to another vendor (even you :-) is just a little step too far for me. Not to mention having to swap gdb for ddbg or whatever it is. I might try porting something simple as an exercise in improving the portability of some code just to see what happens. As Captain Oates said, I may be some time... Bruce.
Oct 08 2007
Walter Bright Wrote:Bruce Adams wrote:I started out trying to use gdc/cygwin and gave up. The general advice I was given was don't do it use dmd. Using gdc on windows puts me in a small minority (anyone else tried it, raise your hand now). Certainly my brief experince was that gdc is too broken on cygwin to use. In my first day of using D I found two compiler bugs one in DMD one in gdc. The one in DMD has a workaround the one in gdc was fatal but I note it has been fixed so I could try again. Finding compiler bugs with "hello world" programs is not a good sign. Bruce.Walter Bright Wrote:When gdc folds this in, then gdc/g++ should also work. I don't know what other issues there are with gdc.A more practical approach is to recompile your C++ source using DMC++.I doubt it is that practical. Though perhaps worth a try. gcc its well integrated with my build system and I keep my code portable between windows and linux. It sounds like I'm out of luck there :(. It was hard enough to persuade myself to try dmd when gdc didn't work for me. I know gcc's interface backwards. Jumping to another vendor (even you :-) is just a little step too far for me. Not to mention having to swap gdb for ddbg or whatever it is. I might try porting something simple as an exercise in improving the portability of some code just to see what happens. As Captain Oates said, I may be some time... Bruce.
Oct 08 2007
Bruce Adams wrote:I started out trying to use gdc/cygwin and gave up. The general advice I was given was don't do it use dmd. Using gdc on windows puts me in a small minority (anyone else tried it, raise your hand now). Certainly my brief experince was that gdc is too broken on cygwin to use. In my first day of using D I found two compiler bugs one in DMD one in gdc. The one in DMD has a workaround the one in gdc was fatal but I note it has been fixed so I could try again. Finding compiler bugs with "hello world" programs is not a good sign.I agree that running into compiler bugs always sucks, but please be sure and report them to bugzilla if they aren't already there. Otherwise, they'll get forgotten and never fixed.
Oct 08 2007
Walter Bright wrote:Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zipThanks, Walter. Especially for bug fixes 1488 and 1125. I suspect the C++ interface stuff will have a big impact on winning over C++ developers.
Oct 09 2007
Don Clugston wrote:Thanks, Walter. Especially for bug fixes 1488 and 1125.You're welcome.I suspect the C++ interface stuff will have a big impact on winning over C++ developers.It's a bit of a shot in the dark. I'm very curious to see how it will work out.
Oct 09 2007
Walter Bright wrote:Don Clugston wrote:I think once this feature matures, another article highlighting the feature will go a long way to making them aware of the feature. It will be interesting to see how/where people plug D into their C++ apps. -JoelThanks, Walter. Especially for bug fixes 1488 and 1125.You're welcome.I suspect the C++ interface stuff will have a big impact on winning over C++ developers.It's a bit of a shot in the dark. I'm very curious to see how it will work out.
Oct 09 2007
janderson wrote:Walter Bright wrote:Another angle is that *no other language* provides any sort of hook into C++.Don Clugston wrote:I think once this feature matures, another article highlighting the feature will go a long way to making them aware of the feature. It will be interesting to see how/where people plug D into their C++ apps. -JoelThanks, Walter. Especially for bug fixes 1488 and 1125.You're welcome.I suspect the C++ interface stuff will have a big impact on winning over C++ developers.It's a bit of a shot in the dark. I'm very curious to see how it will work out.
Oct 09 2007
Walter Bright wrote:janderson wrote:Felix does (and has been around for roughly as long as D). It was explicitly designed around C++ interoperability, and offers all sorts of goodies including extensible syntax, GC, functional capabilities and more. But so far Felix has fewer than 100 users, and probably fewer than 50. D must be doing something right. -- JamesWalter Bright wrote:Another angle is that *no other language* provides any sort of hook into C++.Don Clugston wrote:I think once this feature matures, another article highlighting the feature will go a long way to making them aware of the feature. It will be interesting to see how/where people plug D into their C++ apps. -JoelThanks, Walter. Especially for bug fixes 1488 and 1125.You're welcome.I suspect the C++ interface stuff will have a big impact on winning over C++ developers.It's a bit of a shot in the dark. I'm very curious to see how it will work out.
Oct 09 2007
James Dennett wrote:Walter Bright wrote:knowledge or experience with it.janderson wrote:Felix does (and has been around for roughly as long as D). It was explicitly designed around C++ interoperability, and offers all sorts of goodies including extensible syntax, GC, functional capabilities and more. But so far Felix has fewer than 100 users, and probably fewer than 50. D must be doing something right. -- JamesWalter Bright wrote:Another angle is that *no other language* provides any sort of hook into C++.Don Clugston wrote:I think once this feature matures, another article highlighting the feature will go a long way to making them aware of the feature. It will be interesting to see how/where people plug D into their C++ apps. -JoelThanks, Walter. Especially for bug fixes 1488 and 1125.You're welcome.I suspect the C++ interface stuff will have a big impact on winning over C++ developers.It's a bit of a shot in the dark. I'm very curious to see how it will work out.
Oct 09 2007
Brad Roberts schrieb:knowledge or experience with it.C funktions and specify struct alignments for struct used in these calls. When it comes to interfaces and callbacks/callback interfaces you have to use Managed C++. COM Interop is the keyword, but IMHO, the syntax is sometimes weird and you have to write RCW/CCW (stands for "Runtime Callable Wrapper" and "COM Callable Wrapper") pairs in Managed C++ to support (COM) interfaces. There is a good book about this: http://www.informit.com/store/product.aspx?isbn=067232170X&rl=1
Oct 09 2007
KlausO wrote:C funktions and specify struct alignments for struct used in these calls. When it comes to interfaces and callbacks/callback interfaces you have to use Managed C++. COM Interop is the keyword, but IMHO, the syntax is sometimes weird and you have to write RCW/CCW (stands for "Runtime Callable Wrapper" and "COM Callable Wrapper") pairs in Managed C++ to support (COM) interfaces. There is a good book about this: http://www.informit.com/store/product.aspx?isbn=067232170X&rl=1D has had support for COM from day 1. But D's new support for C++ goes much further. Global functions can be accessed directly, non-COM polymorphic objects can be accessed, and the C++ calling convention is observed (the COM function calling convention is different).
Oct 10 2007
James Dennett wrote:Walter Bright wrote:I'd never heard of Felix :-)Another angle is that *no other language* provides any sort of hook into C++.Felix does (and has been around for roughly as long as D). It was explicitly designed around C++ interoperability, and offers all sorts of goodies including extensible syntax, GC, functional capabilities and more. But so far Felix has fewer than 100 users, and probably fewer than 50. D must be doing something right.
Oct 09 2007
Walter Bright schrieb:James Dennett wrote:Regarding C++ interop. : Comparing Felix and D is a bit unfair. Felix *compiles* to ANSI C++Walter Bright wrote:Another angle is that *no other language* provides any sort of hook into C++.Felix does (and has been around for roughly as long as D). It was explicitly designed around C++ interoperability, and offers all sorts of goodies including extensible syntax, GC, functional capabilities and more. But so far Felix has fewer than 100 users, and probably fewer than 50. D must be doing something right.I'd never heard of Felix :-)http://www.digitalmars.com/d/archives/13809.html :)
Oct 10 2007
Walter Bright schrieb:Bug fixes. New (and very modest) C++ interface. Library module overhauls by Andrei Alexandrescu. Brad Roberts is working behind the curtain to get phobos development much better organized. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.022.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.005.zipThe C++ interface is IMO completely useless . Let me quote Walter "In case that you want D to handle C++ you have to create a complte C++ frontend inside of D" (Not exactly , but I guess I have keeped the meaning) But this is not the point . Porting C++ to D is what should be a piece of cake.. In fact it is not.. Instead of enable us to invoke a very small piece of C++ code I would prefer to make D more C++ compatible. (And I really hate C++) &references ... The Rationales do not say a anything about it The D "compared to C" just says ... We don't have it. Struct inheritance Why we need an *alias here instead of just writing structA : structB; (*D 2.x future docs.) C++ op overloading; D is not competitive. Well there is more. But that's not the point. The point is : Instead of implementing new and outstanding features, enable us to translate (at least) plain C++ code. Actually coding C++ code in D means : rewrite it and make it D-ish, instead of translate it. This is , simply said shit; and I guess you folks know it. OkeeDok just my opinion Bjoern
Oct 09 2007
"BLS" <nanali nospam-wanadoo.fr> wrote in message news:fegotb$1l3e$1 digitalmars.com...Actually coding C++ code in D means : rewrite it and make it D-ish, instead of translate it. This is , simply said shit; and I guess you folks know it.Wow, harsh. There are those of us who don't actually spend all of our time translating C++ into D, you know.
Oct 09 2007
Jarrett Billingsley wrote:"BLS" <nanali nospam-wanadoo.fr> wrote in message news:fegotb$1l3e$1 digitalmars.com...I don't recommend anyone actually translate C++ code to D, or C code for that matter. If it's a debugged, working code base, translating to another language is usually a losing proposition. What matters, though, is being able to interface to that existing code base.Actually coding C++ code in D means : rewrite it and make it D-ish, instead of translate it. This is , simply said shit; and I guess you folks know it.Wow, harsh. There are those of us who don't actually spend all of our time translating C++ into D, you know.
Oct 09 2007
Walter Bright wrote:Jarrett Billingsley wrote:While that sounds like good advice in general, if the C++ library in question is mostly templates, there's not much hope of interfacing to it from D. Porting is the only option I'm aware of. Of course some parts don't translate well and should just be rewritten in a way that makes sense in D. But once the scaffolding is in place, the core, tricky, algorithmic parts that are hardest to debug become easy to translate. So in that way the D port benefits from the work that went into debugging the C++. So it's a win over just writing from scratch. OpenMesh/D is about 15-20K loc. I ported that from C++ in about 10 days. No way I would have been able to write that from scratch in the same amount of time. --bb"BLS" <nanali nospam-wanadoo.fr> wrote in message news:fegotb$1l3e$1 digitalmars.com...I don't recommend anyone actually translate C++ code to D, or C code for that matter. If it's a debugged, working code base, translating to another language is usually a losing proposition. What matters, though, is being able to interface to that existing code base.Actually coding C++ code in D means : rewrite it and make it D-ish, instead of translate it. This is , simply said shit; and I guess you folks know it.Wow, harsh. There are those of us who don't actually spend all of our time translating C++ into D, you know.
Oct 09 2007
Bill Baxter wrote:While that sounds like good advice in general, if the C++ library in question is mostly templates, there's not much hope of interfacing to it from D. Porting is the only option I'm aware of. Of course some parts don't translate well and should just be rewritten in a way that makes sense in D. But once the scaffolding is in place, the core, tricky, algorithmic parts that are hardest to debug become easy to translate. So in that way the D port benefits from the work that went into debugging the C++. So it's a win over just writing from scratch. OpenMesh/D is about 15-20K loc. I ported that from C++ in about 10 days. No way I would have been able to write that from scratch in the same amount of time.I'll agree (from much personal experience) that translating code is a far better option than rewriting from scratch, in order to get it to a different language.
Oct 09 2007
Jarrett Billingsley schrieb:"BLS" <nanali nospam-wanadoo.fr> wrote in message news:fegotb$1l3e$1 digitalmars.com...Yes sure. But in case that you want, respective need to translate, a few D language adjustments would help to save you a lot of time. Well, D2 will have most of the stuff (like struct inherit., opImplicitCast) plus DTL. Maybe I should simply wait..Actually coding C++ code in D means : rewrite it and make it D-ish, instead of translate it. This is , simply said shit; and I guess you folks know it.Wow, harsh. There are those of us who don't actually spend all of our time translating C++ into D, you know.
Oct 10 2007
BLS wrote:Actually coding C++ code in D means : rewrite it and make it D-ish, instead of translate it. This is , simply said shit; and I guess you folks know it.Nope, actually, I don't. If you're so in love with C++, why bother with D? Regards, Frank
Oct 10 2007
0ffh schrieb:BLS wrote:NOOOOOoooo, clarification ;-), I don't like C++, BUT I need to translate some Cpp libs into D. And sometimes it is difficult to do this job 'cause D 1.x actually lacks some of C++ features. (but D 2 comes with struct inheritance., opImplicitCastX, DTL, ....) Bjoern beside, C++ is No 2 on my personal programming language SLActually coding C++ code in D means : rewrite it and make it D-ish, instead of translate it. This is , simply said shit; and I guess you folks know it.Nope, actually, I don't. If you're so in love with C++, why bother with D? Regards, Frank
Oct 10 2007
BLS wrote:0ffh schrieb:I suppose life just isn't fair. =)If you're so in love with C++, why bother with D?NOOOOOoooo, clarification ;-), I don't like C++, BUT I need to translate some Cpp libs into D. And sometimes it is difficult to do this job [...]beside, C++ is No 2 on my personal programming language SLWhat is an SL? Earlier, BLS wrote:&references ... The Rationales do not say a anything about it The D "compared to C" just says ... We don't have it.Yup, and good riddance I say! IMHO even the out/ref keyword is a mistake! (It's also the only mistake of it's kind in Pascal, btw.)Struct inheritance Why we need an *alias here instead of just writing structA : structB;Maybe you have a point here. I suppose mixins can't be used, as there would probably be a problem overriding.C++ op overloading; D is not competitive.Hmmmm.... I can't recall any major issues here. Regards, Frank
Oct 10 2007
0ffh schrieb:BLS wrote:I am pretty sure Gerhard Schroeder still has a top ten placement on George W. Bush's S-List, HTH :)0ffh schrieb:I suppose life just isn't fair. =)If you're so in love with C++, why bother with D?NOOOOOoooo, clarification ;-), I don't like C++, BUT I need to translate some Cpp libs into D. And sometimes it is difficult to do this job [...]beside, C++ is No 2 on my personal programming language SLWhat is an SL?Earlier, BLS wrote:I do not agree, but this is not the point. The problem is that C++ folks seems to love this feature, and I have to translate it into D (somehow).&references ... The Rationales do not say a anything about it The D "compared to C" just says ... We don't have it.Yup, and good riddance I say! IMHO even the out/ref keyword is a mistake! (It's also the only mistake of it's kind in Pascal, btw.)For example : // Allready translated C++ stuff class CFont { public: HFONT m_hFont; this(HFONT hFont = null) { m_hFont = hFont; } ~this() { if(m_hFont !is null && !DeleteObject(m_hFont)) m_hFont = null; } // TODO How to translate this C++ construct into D operator HFONT() {return m_hFont;} // That's the problem. But as allready said/ D 2 opImplicitCast may solve the problem.Struct inheritance Why we need an *alias here instead of just writing structA : structB;Maybe you have a point here. I suppose mixins can't be used, as there would probably be a problem overriding.C++ op overloading; D is not competitive.Hmmmm.... I can't recall any major issues here.Regards, FrankThanks Bjoern
Oct 10 2007
BLS wrote:0ffh schrieb:With the help of explicit pointers and dereferencing, I can see no trouble except you'll need a lot of stars... :) Regards, Frank ps. btw. plain C doesn't have &refs eitherEarlier, BLS wrote:I do not agree, but this is not the point. The problem is that C++ folks seems to love this feature, and I have to translate it into D (somehow).&references ... The Rationales do not say a anything about it The D "compared to C" just says ... We don't have it.Yup, and good riddance I say! IMHO even the out/ref keyword is a mistake! (It's also the only mistake of it's kind in Pascal, btw.)
Oct 10 2007
0ffh schrieb:With the help of explicit pointers and dereferencing, I can see no trouble except you'll need a lot of stars... :) Regards, Frank ps. btw. plain C doesn't have &refs eitherWould be nice if you are willing to offer an example. It could also be used as example on : http://www.prowiki.org/wiki4d/wiki.cgi?PortingFromCxx thanks in advance, Bjoern
Oct 10 2007
BLS wrote:0ffh schrieb:He just means have the function return Foo* instead of Foo&. And then use (*foo) everwhere instead of plain foo on calling side. That's pretty much the only reasonable solution I can see. --bbWith the help of explicit pointers and dereferencing, I can see no trouble except you'll need a lot of stars... :) Regards, Frank ps. btw. plain C doesn't have &refs eitherWould be nice if you are willing to offer an example. It could also be used as example on : http://www.prowiki.org/wiki4d/wiki.cgi?PortingFromCxx thanks in advance, Bjoern
Oct 10 2007
Bill Baxter schrieb:BLS wrote:Thanks for clarification Bill. Wonder why Frank wrote : "except you'll need a lot of * " ? Bjoern0ffh schrieb:He just means have the function return Foo* instead of Foo&. And then use (*foo) everwhere instead of plain foo on calling side. That's pretty much the only reasonable solution I can see. --bbWith the help of explicit pointers and dereferencing, I can see no trouble except you'll need a lot of stars... :) Regards, Frank ps. btw. plain C doesn't have &refs eitherWould be nice if you are willing to offer an example. It could also be used as example on : http://www.prowiki.org/wiki4d/wiki.cgi?PortingFromCxx thanks in advance, Bjoern
Oct 10 2007
BLS wrote:Bill Baxter schrieb:I assumed he meant something like: -- C++ -- void foo(int &i) { ..lots of uses of 'i' eg "i = 5".. } -- D -- void foo(int *i) { ..lots of uses of '*i' eg "*i = 5".. } each usage of a converted ref parameter will require a *. The other problem here however is the call site: -- C++ -- int i; foo(i); -- D -- int i; foo(&i); ReganBLS wrote:Thanks for clarification Bill. Wonder why Frank wrote : "except you'll need a lot of * " ? Bjoern0ffh schrieb:He just means have the function return Foo* instead of Foo&. And then use (*foo) everwhere instead of plain foo on calling side. That's pretty much the only reasonable solution I can see. --bbWith the help of explicit pointers and dereferencing, I can see no trouble except you'll need a lot of stars... :) Regards, Frank ps. btw. plain C doesn't have &refs eitherWould be nice if you are willing to offer an example. It could also be used as example on : http://www.prowiki.org/wiki4d/wiki.cgi?PortingFromCxx thanks in advance, Bjoern
Oct 10 2007
Regan Heath schrieb:BLS wrote:I think : void foo(ref int i){} will do the Job in D ( But function parameters are not part of the problem ) Thanks, BjoernBill Baxter schrieb:I assumed he meant something like: -- C++ -- void foo(int &i) { ..lots of uses of 'i' eg "i = 5".. } -- D -- void foo(int *i) { ..lots of uses of '*i' eg "*i = 5".. }BLS wrote:Thanks for clarification Bill. Wonder why Frank wrote : "except you'll need a lot of * " ? Bjoern0ffh schrieb:He just means have the function return Foo* instead of Foo&. And then use (*foo) everwhere instead of plain foo on calling side. That's pretty much the only reasonable solution I can see. --bbWith the help of explicit pointers and dereferencing, I can see no trouble except you'll need a lot of stars... :) Regards, Frank ps. btw. plain C doesn't have &refs eitherWould be nice if you are willing to offer an example. It could also be used as example on : http://www.prowiki.org/wiki4d/wiki.cgi?PortingFromCxx thanks in advance, Bjoerneach usage of a converted ref parameter will require a *. The other problem here however is the call site: -- C++ -- int i; foo(i); -- D -- int i; foo(&i); Regan
Oct 10 2007
BLS wrote:I think : void foo(ref int i){} will do the Job in D ( But function parameters are not part of the problem )I know that, I was just guessing what 0ffh (aka Frank) was referring to. Regan
Oct 10 2007
Regan Heath schrieb:BLS wrote:Okay Sorry !I think : void foo(ref int i){} will do the Job in D ( But function parameters are not part of the problem )I know that, I was just guessing what 0ffh (aka Frank) was referring to.ReganThe problem is ; //C++ int value = 100; int &rIntRef = value; Bjoern
Oct 10 2007
BLS wrote:Regan Heath schrieb:Except if you try to call foo(42). -- ERROR 42 is not an lvalue (Which is another reason why they're often made const in C++ -- you can pass a literal or temporary to a const T&, but not to a T&. --bbBLS wrote:I think : void foo(ref int i){} will do the Job in DBill Baxter schrieb:I assumed he meant something like: -- C++ -- void foo(int &i) { ..lots of uses of 'i' eg "i = 5".. } -- D -- void foo(int *i) { ..lots of uses of '*i' eg "*i = 5".. }BLS wrote:Thanks for clarification Bill. Wonder why Frank wrote : "except you'll need a lot of * " ? Bjoern0ffh schrieb:He just means have the function return Foo* instead of Foo&. And then use (*foo) everwhere instead of plain foo on calling side. That's pretty much the only reasonable solution I can see. --bbWith the help of explicit pointers and dereferencing, I can see no trouble except you'll need a lot of stars... :) Regards, Frank ps. btw. plain C doesn't have &refs eitherWould be nice if you are willing to offer an example. It could also be used as example on : http://www.prowiki.org/wiki4d/wiki.cgi?PortingFromCxx thanks in advance, Bjoern
Oct 10 2007
BLS wrote:Would be nice if you are willing to offer an example. It could also be used as example on : http://www.prowiki.org/wiki4d/wiki.cgi?PortingFromCxx thanks in advance, BjoernOkay, I am more a C type of person not C++, so I hope I do not write anything wrong now... :) I have a C++ function getting an int &a: ---<snip>--- void addTo(int &a,int b) { a+=b; } void main() { int a=5; addTo(a,3); printf("a=%i\n",a); // prints "a=8\n" } ---<snap>--- IIRC this is really just syntactic sugar for passing a pointer that is automatically dereferenced. In C I replace the &a with an *a and dereference: ---<snip>--- void addTo(int *a,int b) // &a -> *a { (*a)+=b; // a -> (*a) } void main() { int a=5; addTo(&a,3); // a -> &a printf("a=%i\n",a); // prints "a=8\n" } ---<snap>--- This has the added advantage, that at the point where the function is called, I can see that a pointer is passed, while in C++ I can't. That's why C++ coders so often write (const T &ref) to avoid accidential side effects which would be hard to find just looking at the function call. This might work in D, although I have never tried it: ---<snip>--- void addTo(ref int a,int b) { a+=b; } void main() { int a=5; addTo(a,3); printf("a=%i\n",a); // prints "a=8\n" } ---<snap>--- Regards, Frank
Oct 10 2007
0ffh schrieb:BLS wrote:Thanks Frank. Yes the (ref int a) stuff works fine. But function parameters are not part of the problem The problem is ; //C++ int value = 100; int & rIntRef = value; BjoernWould be nice if you are willing to offer an example. It could also be used as example on : http://www.prowiki.org/wiki4d/wiki.cgi?PortingFromCxx thanks in advance, BjoernOkay, I am more a C type of person not C++, so I hope I do not write anything wrong now... :) I have a C++ function getting an int &a: ---<snip>--- void addTo(int &a,int b) { a+=b; } void main() { int a=5; addTo(a,3); printf("a=%i\n",a); // prints "a=8\n" } ---<snap>--- IIRC this is really just syntactic sugar for passing a pointer that is automatically dereferenced. In C I replace the &a with an *a and dereference: ---<snip>--- void addTo(int *a,int b) // &a -> *a { (*a)+=b; // a -> (*a) } void main() { int a=5; addTo(&a,3); // a -> &a printf("a=%i\n",a); // prints "a=8\n" } ---<snap>--- This has the added advantage, that at the point where the function is called, I can see that a pointer is passed, while in C++ I can't. That's why C++ coders so often write (const T &ref) to avoid accidential side effects which would be hard to find just looking at the function call. This might work in D, although I have never tried it: ---<snip>--- void addTo(ref int a,int b) { a+=b; } void main() { int a=5; addTo(a,3); printf("a=%i\n",a); // prints "a=8\n" } ---<snap>--- Regards, Frank
Oct 10 2007
BLS wrote:The problem is ; //C++ int value = 100; int & rIntRef = value;//C int value = 100; int *rIntRef = value; Regards, Frank
Oct 10 2007
0ffh wrote://C int value = 100; int *rIntRef = value;Okay, but only if you don't mind the core dump! =) //C int value = 100; int *rIntRef; rIntRef = &value;
Oct 10 2007
0ffh schrieb:0ffh wrote:int value = 100; int & rIntRef = value; if (rIntRef == 100) // be ashured rIntref = 101 This is why I like refrences, they behave like an alias-name. (and are Not as dangerous as pointers :) Thanks Bjoern//C int value = 100; int *rIntRef = value;Okay, but only if you don't mind the core dump! =) //C int value = 100; int *rIntRef; rIntRef = &value;
Oct 10 2007
BLS wrote:This is why I like refrences, they behave like an alias-name. (and are Not as dangerous as pointers :)To quote Friedrich Nietzsche: "The secret to find the most pleasure in life, is to live dangerously." =) Regards, Frank
Oct 10 2007
0ffh schrieb:BLS wrote:LOL; Man, I am allready married.This is why I like refrences, they behave like an alias-name. (and are Not as dangerous as pointers :)To quote Friedrich Nietzsche: "The secret to find the most pleasure in life, is to live dangerously." =) Regards, Frank
Oct 10 2007