From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: questions on Ada openGL binding in the GLOBE3D packages
Date: Thu, 2 Aug 2012 16:18:05 -0500
Date: 2012-08-02T16:18:05-05:00 [thread overview]
Message-ID: <jveqqh$254$1@munin.nbi.dk> (raw)
In-Reply-To: wccpq795odd.fsf@shell01.TheWorld.com
"Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message
news:wccpq795odd.fsf@shell01.TheWorld.com...
> Brian Drummond <brian@shapes.demon.co.uk> 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.
next prev parent reply other threads:[~2012-08-02 21:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <jvddr3$uqm$1@speranza.aioe.org>
2012-08-02 8:50 ` questions on Ada openGL binding in the GLOBE3D packages Egil Høvik
2012-08-02 9:14 ` Nasser M. Abbasi
2012-08-02 10:19 ` Niklas Holsti
2012-08-02 10:46 ` Nasser M. Abbasi
2012-08-02 11:12 ` Egil Høvik
2012-08-02 11:56 ` Georg Bauhaus
2012-08-02 12:12 ` Vasiliy Molostov
2012-08-02 12:01 ` Vasiliy Molostov
2012-08-02 21:12 ` Randy Brukardt
2012-08-02 20:59 ` Randy Brukardt
2012-08-02 12:13 ` Brian Drummond
2012-08-02 15:01 ` Robert A Duff
2012-08-02 21:18 ` Randy Brukardt [this message]
2012-08-02 23:15 ` Robert A Duff
2012-08-02 15:31 ` Pascal Obry
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox