The CAPI Manifesto

Jonathan M Davis jmdavisProg at gmx.com
Mon Oct 17 17:32:17 PDT 2011


On Monday, October 17, 2011 17:09 so wrote:
> With D being binary compatible with C, i don't know why we worry on such
> things.
> Wasn't being able to access C libraries the point? If it wasn't, what is
> the worthwhile point for this constraint?
> Wouldn't (sorry for the poor horse) separate compilers solve the most
> problems (if not all) we face on these issues?
> C never changes and every compiler vendor have an implementation.
> 
> --
> import anyapi; // anyapi would be a D module or a C header (anyapi.h...)
> in directory paths.
> --
> 
> Structs are pod in both languages.
> Matching of the standard types is something we can take care of with
> documentation (RTFM)
> and with compiler errors generated (when we call functions from the other
> language).
> 
> Sorry once again if this should sound stupid or impossible to implement
> (if so, someone please enlighten me), it probably is because everytime we
> open this discussion i feel i am the only one seeing the big picture, the
> potential of D.

The problem is that for C code to be usable in D code, the C declarations must 
be redone in D, since D can't just include header files. Translating C header 
files to D is a pain and time consuming, and it would benefit us all to have a 
place to go to find common C headers translated to D so that such work doesn't 
have to be duplicated. Hence CAPI has been proposed. And if we're going to 
have it, it also benefits us to be organized about how we lay it out. 
Programmers can name modules in their code whatever they want, but being 
organized about how modules are named and laid out in a large project such as 
this makes it much easier to maintain and find what you want in it.

- Jonathan M Davis


More information about the Digitalmars-d mailing list