On Sat, 04 Oct 2014 11:01:28 +0000 John Colvin via Digitalmars-d-learn <digitalmars-d-learn@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@puremagic.com> > > wrote: > > > >> Sorry, but that's just not how it works. There is no > >> requirement for the definition of a function to be found in > >> the same compilation unit as it's declaration. > > is there any possibility to declare *class* *method* in one > > file and to > > implement it in another? O_O > > > > i doubt so. > > Yes, you can. You just have to get the mangling right. and how about access to class fields? manual mangling is a half-working hack. alas. i really want to have some normal and non-hackish way to separate class definition and class implementation. besides, your trick is faulty, 'cause it misses hidden 'this' parameter. try that: // methodLink.d class A { void foo(int n); } void main () { auto a = new A; a.foo(42); } // missingMethod.d import methodLink; import std.stdio; pragma(mangle, A.foo.mangleof) void foo(int n) { writeln("n=", n); } it writes gibberish and segfaults.
signature.asc
Description: PGP signature