Angry citizen stikes once again. forward references problems

Derek derek at psyc.ward
Sun Jul 30 15:33:58 PDT 2006


On Sun, 30 Jul 2006 21:55:59 +0200, Dawid Ciężarkiewicz wrote:

> Dawid Ciężarkiewicz wrote:
>> In extremal situations you can even get something you can't compile in any
>> way:
>> http://d.puremagic.com/issues/show_bug.cgi?id=104
> 
> I mean:
> http://d.puremagic.com/issues/show_bug.cgi?id=102

I don't understand this Dawid. It seems you are trying to use a nested
class inside another class, and I'm sure you can't and shouldn't do that.

I thought the purpose of nested classes was to restrict the scope of the
nested class to its parent and thus trying to use it outside of the parent
doesn't seem right to me.

Your example..
//  --- test2.d -----
import test2;
class X
{
  Y.NY t;  // ?!? But NY is defined as a nested class in Y.
  static class NX
  {
  }
}
//-------------------------//


//  --- test.d -----
import test;
class Y
{
  X.NX nx;  // ?!? But NX is defined as a nested class in X.
  static class NY
  {
  }
}
//-------------------------//


D won't let you do even the more simple case ...

//------- test3.d -----
class X
{
  static class NX
  {
  }
}

class Y
{
     NX q; // test3.d(10): identifier 'NX' is not defined
}
// -------------------- //

I think dmd is working correctly, though the error messages are not exactly
helpful.

-- 
Derek Parnell
Melbourne, Australia
"Down with mediocrity!"



More information about the Digitalmars-d mailing list