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,5a84d5077c54a29d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!aioe.org!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: Ada array vs C pointer (call by reference) Date: 28 Jun 2008 14:18:03 -0700 Organization: Aioe.org NNTP Server Message-ID: References: <5df91e99-a972-48f7-b466-3eb05dc0a915@m3g2000hsc.googlegroups.com> NNTP-Posting-Host: udTJGbGWl+bx22XXwco3hA.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 Xref: g2news1.google.com comp.lang.ada:942 Date: 2008-06-28T14:18:03-07:00 List-Id: Stephen Leake writes: > Robert A Duff writes: > > Keith Thompson writes: > >> Interfaces.C.C_Float, which (assuming the Ada implementation gets it > >> right), is guaranteed to match C's float, or of using Float, which has > >> no such guarantee (but saves a little typing). Why would you even > >> consider using Float? > > > > You might have a program that uses Float all over the place, > > and you want to add some interface to C in one tiny corner > > of that program. You might be tempted to use Float at the > > interface to C in order to avoid a lot of type conversions. > > A better way to avoid a lot of type conversions is to provide a thin C > interface using Interfaces.C.C_Float, and a thin Ada wrapper that does > the type conversion to Ada.Float (or some other user provided type). That will still involve a lot of type conversions at run time, even if you don't have to write a lot of them in your code. If Float and C_Float happen to have the same representation, that's fine. But if they differ, then the conversions could have bad numeric consequences. To summarize: Programming Is Hard. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Nokia "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"