digitalmars.D.learn - What mean "static nested function"?
- Thorn <Thorn_member pathlink.com> Jun 21 2006
- Kirk McDonald <kirklin.mcdonald gmail.com> Jun 21 2006
Hello, people! I read docs about nested functions and found this sentence: "Static nested functions cannot access any stack variables... blah...". What it mean?
Jun 21 2006
Thorn wrote:Hello, people! I read docs about nested functions and found this sentence: "Static nested functions cannot access any stack variables... blah...". What it mean?
"Stack variable" is another way of saying "local variable," e.g.: int foo(int a) { int i; // This is a stack variable. static int bar(int b) { return b + i; // ERROR! bar is static! } return bar(a); } If bar weren't declared static, then that example would work (it would be able to access foo's stack). As it is, it shouldn't compile. -Kirk McDonald
Jun 21 2006








Kirk McDonald <kirklin.mcdonald gmail.com>