www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D2C

reply "Glen Perkins" <please.dont email.com> writes:
Is there a tool, now or anticipated, for converting D source to C 
source?
Nov 15 2004
parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Glen Perkins wrote:

 Is there a tool, now or anticipated, for converting D source to C source?
Most are trying to convert things the other way around (C2D,H2D) What would the actual use be to convert D source into C source ? --anders
Nov 16 2004
next sibling parent reply John Reimer <brk_6502 yahoo.com> writes:
On Tue, 16 Nov 2004 12:18:41 +0100, Anders F Björklund wrote:

 Glen Perkins wrote:
 
 Is there a tool, now or anticipated, for converting D source to C source?
Most are trying to convert things the other way around (C2D,H2D) What would the actual use be to convert D source into C source ? --anders
For a D backend of sorts; it would allow the programmer to compile his D programs with any C compiler on any system.
Nov 17 2004
parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
John Reimer wrote:

Most are trying to convert things the other way around (C2D,H2D)
What would the actual use be to convert D source into C source ?
For a D backend of sorts; it would allow the programmer to compile his D programs with any C compiler on any system.
For some other languages, it makes sense to have a "compiler" that converts code into C - for actual compilation later on. For instance, GNU Eiffel does this for "Eiffel to C", and at least earlier versions of GNU Ada (GNAT) did as well... But D is compiled directly into object code, and D is a lower level language, so a D2C converter isn't as natural ? You can mix gdc (.d) with gcc (.c) right now, and you can also export routines using the "extern(C)" declarations. Such a D to C converter would be a nice hack, but there are other more urgent issues such as getting D 1.0 released, or improving on the ways of mixing C and D code in a project... (like a better H2D implementation, or how to call D from C?) (or at least a D compiler for MSIL and the .NET platform) --anders PS. GNU Eiffel is located at http://smarteiffel.loria.fr/
Nov 16 2004
parent John Reimer <brk_6502 yahoo.com> writes:
On Tue, 16 Nov 2004 19:11:47 +0100, Anders F Björklund wrote:

 John Reimer wrote:
 
Most are trying to convert things the other way around (C2D,H2D)
What would the actual use be to convert D source into C source ?
For a D backend of sorts; it would allow the programmer to compile his D programs with any C compiler on any system.
For some other languages, it makes sense to have a "compiler" that converts code into C - for actual compilation later on. For instance, GNU Eiffel does this for "Eiffel to C", and at least earlier versions of GNU Ada (GNAT) did as well... But D is compiled directly into object code, and D is a lower level language, so a D2C converter isn't as natural ? You can mix gdc (.d) with gcc (.c) right now, and you can also export routines using the "extern(C)" declarations. Such a D to C converter would be a nice hack, but there are other more urgent issues such as getting D 1.0 released, or improving on the ways of mixing C and D code in a project... (like a better H2D implementation, or how to call D from C?) (or at least a D compiler for MSIL and the .NET platform) --anders PS. GNU Eiffel is located at http://smarteiffel.loria.fr/
Yes, I was thinking of languages such as eiffel when I posted. Whether a D to C compiler is useful or not is debatable, but I was just answering the question. :-) It still might be useful to have a D to C translator for some systems. Linking D with certain compiler-specific C libraries is currently horribly difficult on some systems (especially windows)... Visual C/C++ libraries/dll's, for example, are notoriously problematic to link to from D's and DMD's perspective. A D to C translator could improve interaction with such libraries by allowing the use of the Visual C compiler and link system. It might be fun to test different compiler performance too. But other than for these rather insignificant reasons, there may not be a whole lot of usefulness. Later, John
Nov 17 2004
prev sibling parent "Glen Perkins" <please.dont email.com> writes:
"Anders F Björklund" <afb algonet.se> wrote in message 
news:cncnmh$2q0v$1 digitaldaemon.com...
 Glen Perkins wrote:

 Is there a tool, now or anticipated, for converting D source to C 
 source?
Most are trying to convert things the other way around (C2D,H2D) What would the actual use be to convert D source into C source ?
The basic idea is to make D immediately usable (almost) anywhere C is usable. Imagine an embedded software dev company that works on some small platform requiring a specialized C compiler and an associated suite of related tools (attachable debugger, build manager that scripts their special C compiler, etc.) They have put together a very customized dev process over the years, and GCC isn't part of it. If the developers wanted try using D as a "more productive, safer C", perhaps for some portion of the code, one way to do it would be to write in D, convert it to ANSI C source, and then use that C source as if they had written it by hand. Given the great similarity between D and C, the resulting C could be just as readable (even including the original source comments) and organized very much like the original D. It could be code reviewed, then inserted into the standard build process as if it had been written by hand. If it turned out to be practical in some circumstances (I can't tell for sure--too many issues), D might serve as a sort of fine-grained CASE tool for people who preferred to work in D but were required to work in C, for whatever reason.
Nov 16 2004