How Nested Functions Work, part 1
Michiel Helvensteijn
m.helvensteijn.remove at gmail.com
Wed Sep 2 13:20:34 PDT 2009
Jarrett Billingsley wrote:
> It wouldn't even be that difficult. Basically if you treat
> forward-referenced nested functions as a sort of goto, the same rules
> should apply: a call to a nested function may not skip the
> initialization of any variables it depends on. When i's initializer is
> evaluated, it has not been declared yet, so the call to f is illegal.
> It also prevents other invalid use.
That's what I meant, yes.
Basically, any function that reads i may not be called before i is declared,
nor in i's initialization. Of course, in reality, it depends on the control
flow within the function. But that's holy grail stuff. So: conservatively.
--
Michiel Helvensteijn
More information about the Digitalmars-d
mailing list