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,43d910f082521047 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.180.95.2 with SMTP id dg2mr527247wib.2.1343942291267; Thu, 02 Aug 2012 14:18:11 -0700 (PDT) MIME-Version: 1.0 Path: q11ni10816155wiw.1!nntp.google.com!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.x-privat.org!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: questions on Ada openGL binding in the GLOBE3D packages Date: Thu, 2 Aug 2012 16:18:05 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1343942289 2212 69.95.181.76 (2 Aug 2012 21:18:09 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 2 Aug 2012 21:18:09 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2012-08-02T16:18:05-05:00 List-Id: "Robert A Duff" wrote in message news:wccpq795odd.fsf@shell01.TheWorld.com... > Brian Drummond writes: > >> "Making code look the same as C" is ... not unambiguously better! > > True. > > But sticking closely to the C does have the advantage that > the binding doesn't need a whole lot of documentation (which > must be maintained) -- you can just refer to the C docs. > A thick binding requires a lot of documentation. > > IMHO, the name changes are so systematic in this case, that > it's close enough -- you can still refer to the C docs, > and do the trivial translation in your head. And the Ada names > really are more readable. I think it's the right choice, > especially since the standard actually suggests doing it > this way in languages that have a proper module system. > > What if you had a system originally written in Ada (with appropriate use > of overloading), and you wanted to make a C binding? In that case it > would be impossible to make the names the same. > > I once wrote an Ada binding to some C code where every C function > returned an 'int' as an error code, with 0 meaning "success". > I did it in two layers. A thin binding that worked the same > way, returning Interfaces.C.int. Then a layer on top of that > that turned the error codes into raising an exception. The second > layer is such a systematic change that I think it can still > be considered "thin" -- thin enough that the C documentation > still makes sense. I think calling that "thin" is dubious. I call the technique "medium" for a lack of a better term, and it has to include normalizing the names, adding appropriate defaults, and using Ada parameter modes appropriately (along with raising exceptions). But I agree that it makes reading C documentation easier than for a true "thick" binding -- the problem being, that no one should be forcing Ada programmers to read C documentation. Cost considerations of course make that necessary sometimes, but even then I would hope that there would at least be some Ada-specific documentation covering common use-cases. Randy.