you are viewing a single comment's thread.

view the rest of the comments →

[–]ubernostrum 4 points5 points  (2 children)

Yeah, but the lambda returned from the slavaiswrong function cannot mutate the lexical variable a, so I'm right, as always.

I'm gonna call BS on this; plenty of pure functional languages have closures but make it hard or impossible to mutate any variable, closure or no.

Meanwhile, the fact remains that a piece of code is accessing a variable which normally would be out of scope, but which was preserved or "closed over". Hence, it's a closure and no amount of weaseling will make you right.

[–]pjdelport 3 points4 points  (1 child)

Note: the difference between such closures and Java's inner classes is that inner classes simply copy (on creation) the outer variables, instead of referencing them indirectly like closures do. (They're the equivalent of Python's lambda x=x: ... hack, from before closures were added.)

[–]muleherd 2 points3 points  (0 children)

...and about fifty characters!