My two cents
Satoshi
satoshi at rikarin.org
Tue Oct 24 07:21:56 UTC 2017
On Monday, 23 October 2017 at 20:47:26 UTC, Walter Bright wrote:
> On 10/18/2017 1:56 AM, Satoshi wrote:
>> Unable to publish closed source library without workaround and
>> ugly PIMPL design.
>
>
> Consider this:
>
> ----------- file s.d ------------
> struct S {
> int x;
> this(int x) { this.x = x; }
> int getX() { return x; }
> }
> ----------- file s.di ------------
> struct S {
> this(int x);
> int getX();
> }
> --------------------------
>
> User code:
>
> import s;
> S s = S(3);
> writeln(s.getX());
>
> Ta dah! Implementation is hidden, no PIMPL. Of course, inlining
> of the member functions won't work, but it won't work in C++,
> either, when this technique is used.
>
> I.e. you can use .di/.d files just like you'd use .h/.cpp in
> C++. The technique works with classes, too.
what about this:
---------- file.d
class Foo {
private int bar;
private string text;
void call() { }
}
----------- file.di
class Foo {
call();
}
and then I want to inherit from it (I have access to file.di only)
class Bar : Foo { // I cannot due I have misleading information
about size of Foo
}
More information about the Digitalmars-d
mailing list