Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can and can't go in a D interface file?

Tags:

d

I've just read this, and I'm a little confused about what D interface files can and can't contain. That page isn't terribly clear about that (although it spends time explaining their benefits).

like image 905
Koz Ross Avatar asked Mar 18 '23 21:03

Koz Ross


1 Answers

.di and .d files are identical as far as the compiler is concerned. (literally, it treats both exactly the same as D source).

You can put as much or as little as you want in them, as long as the interface is indeed compatible with the library code. It is your responsibility to keep the interfaces in sync - if you change a function signature in the main library code, you must change it (or regenerate the .di from the main .d file) in the interface too, the compiler will not check them for you.

I don't use .di files personally, I think their only practical benefit is if you are writing a closed source library.

like image 166
Adam D. Ruppe Avatar answered Mar 23 '23 07:03

Adam D. Ruppe