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,21960280f1d61e84 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Fri, 26 Jan 2007 06:29:16 +0100 From: Gautier User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How come Ada isn't more popular? References: <1169531612.200010.153120@38g2000cwa.googlegroups.com> <51m6rqF1kqpr0U1@mid.individual.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 85.0.155.80 X-Original-NNTP-Posting-Host: 85.0.155.80 Message-ID: <45b99191_1@news.bluewin.ch> X-Trace: news.bluewin.ch 1169789329 85.0.155.80 (26 Jan 2007 06:28:49 +0100) Organization: Bluewin AG Complaints-To: abuse@bluewin.ch X-Original-NNTP-Posting-Host: 127.0.0.1 Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!164.128.36.58!news.ip-plus.net!newsfeed.ip-plus.net!news.bluewin.ch!not-for-mail Xref: g2news2.google.com comp.lang.ada:8584 Date: 2007-01-26T06:29:16+01:00 List-Id: Dr. Adrian Wrigley: > I think this is critical. Why can't we just say: > > with stdio; > > pragma import (C, stdio, "stdio.h"); > > and be able to get structs, functions, constants, variables from C in > an obvious and reasonably reliable way? > > Much of what is in C has direct analogs in Ada. Some of it is via > fiddly #defines, but even a useful subset of these would be e A problem is that you will want to import something else than "stdio.h", for instance "XYZ.h" which contains #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) # define WIN32_LEAN_AND_MEAN # define NO_MIN_MAX # include # undef min # undef max ... or worse messes... You need the whole #include and #define preprocessing, admit that "with ABC, XYZ;" may well behave differently than "with XYZ, ABC;" and plenty of funny things! In addition, I guess that with this "feature" each Ada compiler and compiler version would still behave slightly differently in that respect, with big differences at the bottom line. That way you quickly scale down most interesting aspects of Ada: non-flat modularity, strong typing (Keith's reply), portability and probably more. It is a bit too much retro-computing for Ada, I'm afraid. You'd better to write a preprocessor that takes XYZ.h plus the pre-defined-#define's as input, and spits XYZ.ads as output with the Import pragmata. You can take a look at the preprocessor I made for Borland Pascal / Delphi, BP2P, in newp2ada.zip there: http://www.mysunrise.ch/users/gdm/gsoft.htm#p2ada > And of course compilers should spit out header files on request > matching an ada package via the "obvious" rules, so you can > #include it from C. For that, again, you don't need to wait an (IMHO) unlikely change in the standard; especially the because the "obvious" is maybe not so clear to define - or is it ? You have all ingredients to make a nice tool: tons of Ada yacc grammars on the Internet, even an up to date ayacc/aflex if you want to do your tool in Ada (see again newp2ada.zip). The "obvious and reasonably reliable way" of importing C stuff is certainly more something soft (just like C itself) that you can express better in doing import/export tools than something solid you can define in an Ada standard... ______________________________________________________________ Gautier -- http://www.mysunrise.ch/users/gdm/index.htm Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm NB: For a direct answer, e-mail address on the Web site!