From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,58253cbf46bbb1fc X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!62.253.162.218.MISMATCH!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!news.highwinds-media.com!newspeer1-win.ntli.net!newsfe5-win.ntli.net.POSTED!53ab2750!not-for-mail From: "Dr. Adrian Wrigley" Subject: Re: Automated conversion to C++? User-Agent: Pan/0.14.2.91 (As She Crawled Across the Table (Debian GNU/Linux)) Message-Id: Newsgroups: comp.lang.ada References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Sat, 16 Feb 2008 13:43:58 GMT NNTP-Posting-Host: 82.21.106.242 X-Complaints-To: http://netreport.virginmedia.com X-Trace: newsfe5-win.ntli.net 1203169438 82.21.106.242 (Sat, 16 Feb 2008 13:43:58 GMT) NNTP-Posting-Date: Sat, 16 Feb 2008 13:43:58 GMT Organization: NTL Xref: g2news1.google.com comp.lang.ada:19818 Date: 2008-02-16T13:43:58+00:00 List-Id: On Fri, 15 Feb 2008 14:33:08 +0100, Jacob Sparre Andersen wrote: > I have been offered to take part in a programming project with a > rather annoying constraint: There should be C++ source available for > the constructed program. > > The good part is that I am allowed to do the actual programming in > Ada, and just use an automated translator to generate the C++ code. If you have to supply a C++ program semanticly equivalent to the binary you deliver, the best choice is to write it in pure C (or C++). You are guaranteed equivalence. You need find no translators. You have no mismatches in runtime. The risk is low. C++ makes so many Ada capabilities a real nuisance to implement. Basics like enumerations with constraint checks, fixed point types, floating point attributes, integer over/underflow exceptions need loads of messy C++ (often with specialized headers) to implement. When it comes to rendezvous, elaboration, real-time, ATC and anything from Annex E,(or D or G), you are really stuck with no obvious mapping. If you are interfacing to hardware, you hit the limitation that you can't do representation clauses in C++. The nearest thing is by unpacking bit fields manually, making assumtions about the layout in C++ (which are not part of the language spec). In short, to deliver a C++ program: Simple program => Write it in C because translation takes too much time Complex program => Write it in C because the translation is impossible If a customer is paying to get C++ source, don't write it in Ada - they presumably don't care for a robust, low-defect solution. If they did, they would put constraints on the C++ (eg must run at least 80% of the speed. Use no more than 1.3x the memory) Just my opinion. -- Adrian