www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D should disallow forward references

reply grauzone <none example.net> writes:
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.

Why? Because it reduces confusion and frustration for the programmer, 
because the compiler actually *works*. A programmer won't get confused 
over buggy language features anymore; the confusion gets replaced by 
clear and straight forward rules. It also solves all problems related to 
circular module dependencies.
Aug 25 2009
next sibling parent Michiel Helvensteijn <m.helvensteijn.remove gmail.com> writes:
grauzone wrote:

 Conclusion: other than trying to keep a buggy feature, that isn't going
 to be fixed, remove it from the language.
A bit silly, since it's really quite easy. It just requires an extra compiler pass. Any constant data should be forward referenceable. That means functions, types and const (immutable, enum, etc.) symbols/vars. Seems to me like reference resolving is one of the first things that should work correctly. I'd drop everything and fix this bug before working on anything else. :-) -- Michiel Helvensteijn
Aug 25 2009
prev sibling parent Stewart Gordon <smjg_1998 yahoo.com> writes:
grauzone wrote:
<snip>
 For a general overview of forward reference bugs, just search Bugzilla:
 http://d.puremagic.com/issues/buglist.cgi?quicksearch=forward+reference
<snip> http://d.puremagic.com/issues/show_bug.cgi?id=340 Stewart.
Aug 25 2009