Open
Description
Given example creates 5 real arrays and 2 unit arrays (using ech separate array for each doAfter closure even though they are members of same abstract class and can't overlap (sorry if I miss something)) even though it should be possible to use only 3 real arrays and 1 unit array in implementation. It's not a problem in smaller projects but in big projects this would easily create 100+ global arrays of same type even though every closure uses only 1-3 different variables of same type.
import ClosureTimers
init
let r1 = GetRandomReal(0., 1.)
let r2 = GetRandomReal(0., 1.)
unit u = null
let r3 = GetRandomReal(0., 1.)
doAfter(2.) ->
print(r1.toString())
doAfter(3.) ->
print(r2.toString())
print(u.getName())
doAfter(4.) ->
print(r3.toString())
print(r2.toString())
print(r1.toString())
print(u.getName())`
Sorry if I was unclear.