What are modules for?
Simen kjaeraas
simen.kjaras at gmail.com
Thu Nov 25 16:16:36 PST 2010
rickned <nospam at nospam.net> wrote:
> Modules, files, packages, compilation units...
>
> I have a class that is designed to be derived from. Can I put it in
> a module (file) so other people can import the module (file) like a
> C-c++ header so they can derive from it?
Yes. Any non-final public class in an imported module can be derived
from.
> Is that the idomatic way to do that in D?
There is the option of using a .di file, if you want to hide
implementation. .di files are normal D source files, with
implementation stripped. Due to the compilation speed (I believe) and
no requirement to hide implementation, most projects I've seen simply
use .d files.
> I don't want to expose the method definitions,
> mind you. I understand deeply the C++ way of doing things like
> hiding implementation and interfaces etc. Can someone bring it all
> together for me in D?
See above. .di files are basically what you'd expect to be the D
equivalent of a .h file.
> And note that the hiding part is not the gist
> of my question, but rather that I want to understand the D way but
> am probably trying to contrast it to the C++ way. I have TDPL
> (borrowed from the library, and it's a one without Andy's name on
> the cover), but I started reading it in the module chapter but
> found it rather confusing, if not lacking all the pertinent info.
--
Simen
More information about the Digitalmars-d
mailing list