| 133 | In this case, counter "closes" over the a lexical variable "a" and prevents it from going out of scope. A useful feature of closing over a variable with a function is that you can sometimes eliminate the need to maintain global data structures for your program. The API for the client, for example, when it loads a quagent into the environment, creates a new socket and then closes over it with methods that read and write messages to the server. As a consequence, there is no need to explicitly store the connection information anywhere, and code is simplified considerably. |