digitalmars.D.bugs - Can't Forward Reference Nested Functions
- Russ Lewis (3/10) Jan 18 2005 DMD complains with the following error:
- J C Calvarese (9/19) Jan 19 2005 Perhaps the error message could be improved, but the spec mentions that ...
- Russ Lewis (8/17) Jan 19 2005 Hmmm. Didn't notice that. Well, I guess that it's fair if it's
- Walter (4/9) Jan 19 2005 To fix it, the semantic pass for function bodies would have to be rewrit...
Linux (Fedora Core 1), DMD 0.110 I can't call nested functions that I haven't defined yet.void main() { nestedFunc(); void nestedFunc() {}; }DMD complains with the following error:cant_forward_reference_nested_funcs_bug.d(2): undefined identifier nestedFunc cant_forward_reference_nested_funcs_bug.d(2): function expected before (), not 'int'
Jan 18 2005
In article <csk4ne$2njc$2 digitaldaemon.com>, Russ Lewis says...Linux (Fedora Core 1), DMD 0.110 I can't call nested functions that I haven't defined yet.Perhaps the error message could be improved, but the spec mentions that this code isn't allowed: "Unlike module level declarations, declarations within function scope are processed in order. This means that two nested functions cannot mutually call each other." (http://www.digitalmars.com/d/function.html) Hopefully someday we'll be able to use nested functions before they are defined, but at least this limitation is mentioned in the spec. jcc7void main() { nestedFunc(); void nestedFunc() {}; }DMD complains with the following error:cant_forward_reference_nested_funcs_bug.d(2): undefined identifier nestedFunc cant_forward_reference_nested_funcs_bug.d(2): function expected before (), not 'int'
Jan 19 2005
J C Calvarese wrote:Perhaps the error message could be improved, but the spec mentions that this code isn't allowed: "Unlike module level declarations, declarations within function scope are processed in order. This means that two nested functions cannot mutually call each other." (http://www.digitalmars.com/d/function.html) Hopefully someday we'll be able to use nested functions before they are defined, but at least this limitation is mentioned in the spec.Hmmm. Didn't notice that. Well, I guess that it's fair if it's documented :/ I am very curious though, Walter, what the reason for this is. Just speaking as a programmer, I'd be fascinated to understand why this requirement exists. It would seem (from the outside) that whatever code you use use handle forward references in general could be leveraged to also handle this case.
Jan 19 2005
"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message news:csm3d1$2oda$1 digitaldaemon.com...I am very curious though, Walter, what the reason for this is. Just speaking as a programmer, I'd be fascinated to understand why this requirement exists. It would seem (from the outside) that whatever code you use use handle forward references in general could be leveraged to also handle this case.To fix it, the semantic pass for function bodies would have to be rewritten to be multipass, and it seems a low priority to do that.
Jan 19 2005