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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,87077e61d6b3095b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-21 05:41:35 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!skynet.be!freenix!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: how do i implement double-dispatching? Date: 21 Dec 2003 08:39:59 -0500 Organization: Cuivre, Argent, Or Message-ID: References: <18484099.QgktZUUZ8s@linux1.krischik.com> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: melchior.cuivre.fr.eu.org 1072014028 30960 80.67.180.195 (21 Dec 2003 13:40:28 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Sun, 21 Dec 2003 13:40:28 +0000 (UTC) Cc: comp.lang.ada@ada-france.org To: cl1motorsports Return-Path: In-Reply-To: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 X-Virus-Scanned: by amavisd-new-20030616-p5 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.3 Precedence: list List-Id: Gateway to the comp.lang.ada Usenet newsgroup List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:3665 Date: 2003-12-21T08:39:59-05:00 cl1motorsports writes: > On Sat, 20 Dec 2003 10:56:07 +0100, Martin Krischik wrote: > > > Have you considered to send the C file thrue the C preprocessors > > and convert the output? #if #define etc. pp. will be cone by then. > > What's the fun in that? Seriously though, the most common preprocessor is > the one that comes with gcc, and it puts alot of non standard C stuff in > its output. Hmm. I never noticed anything that was not in the ANSI C standard. Are you sure it is truly not in that standard? Or is it just something you are not familiar with? In any case, you can disable any non-standard stuff by specifying -ansi. > That is one reason I didn't want to do that. Another reason is > because some people may want to convert a whole project and want to > keep the preprocessed code. I think you mean "translate the preprocessor statements into Ada, to preserve structure". That is a good idea. > I already have some ideas on this > > #define FOO > Foo : constant Boolean := True > > #define FOO "i'm a string" > Foo : constant String(1..12") := "i'm a string"; > > #define FOO 12 > Foo : constant := 12; > > #define MAX(a,b) (a < b) b ? a; > generic > type blah is <>; > function Max(a : blah; b : blah) return blah is > begin > if (a < b) then > return b; > else > return a; > end if; > end Max; > function > > that's just a few examples. This will work for many common uses of the preprocessor. Of course, it will not be possible for _all_ uses of the preprocessor. But then your translator can either run the C preprocessor and use the output, or issue an error about untranslatable code. > I also want to use the define statements to be able to produce > generic packages. I've got a direct conversion for most types of > #define statements (i think) except ones with the stringize and > concatination operators, and the ones that are just down right messy > (garbage in garbage out). Right. Those should be re-written anyway :). -- -- Stephe