[e-lang] objects <-> closures (was: Wiki Software)
Sandro Magi
smagi at higherlogics.com
Tue Feb 27 10:34:11 CST 2007
Sandro Magi wrote:
> Tyler Close wrote:
>> I disagree with the parable on that page. Object does not imply
>> lexical closure. C++ has objects, but does not have lexical closures.
>> You can understand objects in terms of lexical closures, but not
>> vice-versa.
>
> You certainly can: a closure is simply an object where the lexically
> captured variables are exposed in the object's constructor. This is how
> many FP languages implement closures on the JVM and .NET VM.
Naturally, this technique already has a name which I just stumbled
across: defunctionalization [1]. It's a well-known meaning-preserving
transformation of higher-order programs into first order programs.
Sandro
[1] http://www.haskell.org/hawiki/DeFunctionalization
More information about the e-lang
mailing list