Talk:Closures/Value capture

From Rosetta Code

Sample output

Sample output is always useful in the task description.
While the task says display, the requirement is there but what is left up to the implementer.
The Python example does not show it's output.

--Dgamey 11:33, 20 July 2011 (UTC)

The Python expected output seems to be in comments after the prin statements. --Paddy3118 12:39, 20 July 2011 (UTC)

Function description a bit vague

A bit more specification/clarity would be helpful. I think I understand, but I shouldn't have to read one of the code examples to be sure.
The description "such that the function at index i (i from 0 to 9), when run, should return the number i." sounds like the function just returns its argument. It says nothing about how the return value behaves. It looks like we are meant to use a closure to create what is effectively a constant.
I misinterpreted this as its parametric position at first, but I think it means its position within a list. What happens if the list is as follows?: a(), b(), a(),
Should the first a() give 1, b() give 2, and the second a() give 3? Markhobley 12:06, 20 July 2011 (UTC)
It seems to create a list of 10 elements with each element being a call to the same function bound to the index position. Which is why it struck me that it is using a closure to simulate a constant. (Mind you shuffling the list elements could then be fun). --Dgamey 13:09, 20 July 2011 (UTC)
Why 10 functions? Surely two or three would be sufficient to demonstrate how this works? The python example seems to put these in a list.

--Dgamey 11:46, 20 July 2011 (UTC)