Re: Nested functions - better example?
- Posted by Spock Jan 07, 2021
- 1037 views
According to this a closure is a persistent local variable scope. For Orac what I did was this:
function f() static int x = 2 // persistent var here initialised at runtime int y = x + 1 return y end function
The code "compiles" to:
int x = 2 // only accessed by the function function f() int y = x + 1 return y end function
That gives me persistent private variables. It would, of course, end up being shared across multiple calls to the function. But I never needed anything smarter than that. Or nested functions.
Spock