Closed dido18 closed 9 years ago
In FSharp we connot use a mutable variable in a anonymous function The program in FunW@p
fun outside_adder() fun(int) int { var sum int = 10 return fun(x int) int { sum += x return sum } }
is translated in fsharp:
let outadd = let mutable sum = 10 fun x -> sum <- sum + x sum
But mutable variable sum is used in an invalid way, because variables cannot be captured by closures. there are two possibilities:
fixed using ref everywhere and closures
In FSharp we connot use a mutable variable in a anonymous function The program in FunW@p
is translated in fsharp:
But mutable variable sum is used in an invalid way, because variables cannot be captured by closures. there are two possibilities: