www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Library inheritance

reply "Felix" <fmarezki gmail.com> writes:
Hi,
just wondering if it's possible, due to the lag of header files, 
to inherit from some class that exists within a library, that has 
been written in D?

How did you solve that?

Thanks in advance.
Nov 04 2014
next sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
A library may provide header files for this, or you can just use 
the source code itself to import and inherit from.
Nov 04 2014
parent reply "Felix" <fmarezki gmail.com> writes:
On Tuesday, 4 November 2014 at 15:27:33 UTC, Adam D. Ruppe wrote:
 A library may provide header files for this, or you can just 
 use the source code itself to import and inherit from.
Okay, but that would mean to have the source available. Though for me it seems like D is attempting to get rid of header files. But when dealing with, lets say, some D compiled library there seems to be now way to accomplish something like inheriting as ELF doesn't provide you with the necessary data.
Nov 05 2014
parent "David Nadlinger" <code klickverbot.at> writes:
On Wednesday, 5 November 2014 at 23:04:00 UTC, Felix wrote:
 On Tuesday, 4 November 2014 at 15:27:33 UTC, Adam D. Ruppe 
 wrote:
 A library may provide header files for this, or you can just 
 use the source code itself to import and inherit from.
Okay, but that would mean to have the source available.
You can still use a version of the source code without any of the function bodies (usually ending in .di). Same as in C++, more or less. David
Nov 05 2014
prev sibling parent "Chris Williams" <yoreanon-chrisw yahoo.co.jp> writes:
On Tuesday, 4 November 2014 at 15:03:08 UTC, Felix wrote:
 Hi,
 just wondering if it's possible, due to the lag of header 
 files, to inherit from some class that exists within a library, 
 that has been written in D?

 How did you solve that?

 Thanks in advance.
You can run the compiler to create library and header (.di) files. Anything that requires compile-time execution, like templates, will remain in the .di. Anything that can be compiled as-is, will go in the library and just be represented as a function/method declaration in the .di file. So, basically, the same as C++ except you don't have to manually write your own header files.
Nov 05 2014