D should disallow forward references

Jarrett Billingsley jarrett.billingsley at gmail.com
Tue Aug 25 07:52:40 PDT 2009


On Tue, Aug 25, 2009 at 10:19 AM, grauzone<none at example.net> wrote:
> Right now, D seems to *intend* to allow arbitrary forward references of
> types and functions. But the reality is different. dmd accepts some forward
> references, but chokes up on others. For example, forward references to
> classes are normally no problem, while enums can't be forward referenced at
> all. (Which is funny; you'd think that enums are simpler than classes.)
> Structs often require creative rearrangement of source code to make them
> work.
>
> For a general overview of forward reference bugs, just search Bugzilla:
> http://d.puremagic.com/issues/buglist.cgi?quicksearch=forward+reference
>
> I think you can say, that forward referencing is quite incomplete and buggy
> in dmd. Even worse, it bothers the programmer in everyday programming. The
> programmer gets the feeling, he's doing more work working around compiler
> bugs, than on his program. There's nothing worse than a core language
> feature, that doesn't work as advertised.
>
> Unfortunately, Walter seems to consider these bugs as minor issues, and
> apparently, he thinks that amount of work fixing them doesn't pay off.
> Although he often fixes some related bugs here and there, the problem
> remains.
>
> Conclusion: other than trying to keep a buggy feature, that isn't going to
> be fixed, remove it from the language.

For one, easier said than done.  You'd have to introduce forward
declarations a la C++ in order to make something like this.

For two, NO.  Disallowing forward references sucks.  It's entirely
possible to implement a compiler that resolves forward refs correctly.
 If W doesn't want to do it, that's on him.



More information about the Digitalmars-d mailing list