Code fails with linker error. Why?
eles via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Oct 6 03:10:02 PDT 2014
On Saturday, 4 October 2014 at 15:29:57 UTC, John Colvin wrote:
> On Saturday, 4 October 2014 at 11:19:52 UTC, ketmar via
> Digitalmars-d-learn wrote:
>> On Sat, 04 Oct 2014 11:01:28 +0000
>> John Colvin via Digitalmars-d-learn
>> <digitalmars-d-learn at puremagic.com>
>> wrote:
>>
>>> On Saturday, 4 October 2014 at 10:38:32 UTC, ketmar via
>>> Digitalmars-d-learn wrote:
>>> > On Sat, 04 Oct 2014 10:27:16 +0000
>>> > John Colvin via Digitalmars-d-learn
>>> > <digitalmars-d-learn at puremagic.com>
>>> > wrote:
> I don't really see the point though.
>
> class A
> {
> void foo(int a) { Afoo(this, a); }
> }
>
> then declare and define Afoo however you like.
That's hackish, bad and convoluted. And it does not/should not
allow one to mess with the private fields of the class,
especially if Afoo is defined in another module.
And on that matter, a function that is to be provided by another
module should be explicitly marked as such in its declaration.
Otherwise, I could declare a function, forget to provide its
definition, still having the surprise that the code compiles and
runs with very strange results because some other module provides
a function that just happens to work.
Let's not even say how messy this could get with version() where
you could disable a function definition by error, in one version,
but still have a software that compiles and runs nowhere.
More information about the Digitalmars-d-learn
mailing list