[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How can I learn about Object Oriented programming with lua?
- From: Jorge <xxopxe@...>
- Date: Thu, 27 Feb 2014 16:28:08 -0200
On 02/27/2014 04:06 PM, Steve Litt wrote:
I must be missing something here, because I never thought of closures
as mindblowingly powerful. First, maybe I have the wrong idea of what a
closure is. I thought it was an inner function contained in an outer
function, where the inner function is passed back as the return of the
outer function, and the inner function can see and modify the outer
function's local variables, but each newly returned inner function
starts over with the vars set by the outer function, so four returned
inner functions can operate completely independently of each other. Am
I right so far?
I think that so.
What finally impressed me about closures is how they make objects work
without even thinking in that terms. Not even syntax to signal what an
object is. You just declare some variables, return some functions and
*BAM* you have objects. You only have to declare the variables in the
scope where they make sense.
To be honest, it's a bit unsettling.