"Jarrett Billingsley" <[email protected]> wrote in message news:[email protected]... > On Wed, Sep 2, 2009 at 3:29 PM, Don<[email protected]> wrote: >> Michiel Helvensteijn wrote: >>> >>> Rainer Deyke wrote: >>> >>>> That can lead to subtle problems in the case of functions: >>>> >>>> int i = f(); >>>> int f() { return i; } >>> > > 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.
Sounds like a good reason to take the C# approach to variable initialization: No default values, just disallow reading or taking a reference to a var that hasn't *clearly* been initialized. Or maybe default-init i to int.init, and then set it to f(), but that's probably not nearly as good.
