Static opCall Factory Method Doesn't Work for Inner Classes
Simen kjaeraas
simen.kjaras at gmail.com
Tue Jan 12 09:10:26 PST 2010
eris <jvburnes at gmail.com> wrote:
> Every syntax combination in D to express a static opcall on an inner
> class doesn't work. Both 'ldc' and 'gdc' generate compiler errors that
> say that 'this' is not available for static opCalls. When I take the
> 'static' keyword off the opCall declaration the compiler error becomes
> something like: 'this' is required to access the opCall method.
Does the inbox need a pointer to the kernel class? If so, you're ferked.
Well, not really, but then you have to explicitly pass it to opCall.
See, to get this to work, you do this:
class foo {
static class bar { // static inner classes have no 'outer' pointer
static bar opCall( ) {
return new bar( );
}
}
}
Hope this helps.
--
Simen
More information about the Digitalmars-d-learn
mailing list