C to D bindings: how much do you D-ify the code?

Mike Parker aldacron at gmail.com
Fri Oct 25 07:26:21 PDT 2013


On 10/25/2013 10:10 PM, Lionello Lunesu wrote:
>
> These are some of the more trivial ones, but I'd like to see how other
> people go about making bindings. Do you keep as close to C as possible?
> Or do you "add value" by using more D style constructs?
>

IMO, a binding to an existing library should never add anything extra if 
it is intended to be released to the public. It should adhere as closely 
as possible to the C API. This is especially important if the C library 
is well-known. It would mean that existing sample code, tutorials and so 
on would require minimal adjustment to work in D. In that case, the 
two-step process recommended in other replies is the way to go. If it's 
for internal use only, then I think it doesn't really matter either way 
(with the caveat that D-ifying the binding may increase maintenance 
costs when the C library is updated -- but I don't think it's so high 
anyway).

However, if it were me and I weren't binding an existing C library but, 
instead, developing a new one and a D binding to go along with it, I 
would be more inclined to D-ify the binding in that case.



More information about the Digitalmars-d mailing list