www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Forward declarations under certain situations?

reply Geordi <Geordi_member pathlink.com> writes:
Apologies if this has already been asked,

code:

class A{
B b;
enum B { x,y,z }
}

Produces this error:
enum B is forward referenced

It was my understanding that D did not require forward declarations, the
existance of this error message implies that this is an error by design. Am I
missing something?
Jan 12 2005
next sibling parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Geordi wrote:
 Apologies if this has already been asked,
See my post today on digitalmars.D.bugs. <snip>
 Produces this error:
 enum B is forward referenced
 
 It was my understanding that D did not require forward declarations, the
 existance of this error message implies that this is an error by design. Am I
 missing something?
This aspect of the language is slowly working its way in. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Jan 12 2005
prev sibling parent "Walter" <newshound digitalmars.com> writes:
"Geordi" <Geordi_member pathlink.com> wrote in message
news:cs37sk$1lll$1 digitaldaemon.com...
 Apologies if this has already been asked,

 code:

 class A{
 B b;
 enum B { x,y,z }
 }

 Produces this error:
 enum B is forward referenced

 It was my understanding that D did not require forward declarations, the
 existance of this error message implies that this is an error by design.
Am I
 missing something?
No, you're not missing anything. Enums just haven't gotten the attention they need in the internal compiler workings to support forward referencing yet. The last compiler update went through some significant internal work to get structs to forward reference right. It'll happen for enums, too, it's just a lower priority.
Jan 12 2005