Content deleted Content added
TexasAndroid (talk | contribs) →Removed "merge this with Function object" note: disambiguation link repair (You can help!) |
CarlHewitt (talk | contribs) No edit summary |
||
Line 1:
==Closures in Perl==
In perl at least, a closure doesn't have to be a function definition. It's more or less anything between a pair of braces, that serves as it's own variable scope. In Damian Conway's ''Object Oriented Perl'', I believe he uses closures to implement the private variables of an object, so it might be misleading to say that the closure itself is an object or acts like one. In any case, something needs to be said about scope here. [[user:Wesley|Wesley]]
Line 67 ⟶ 68:
----
==Closures and Java==
I have just edited the page such that the [[Java programming language|Java]] simulation section has "<tt>final</tt>" instead of "immutable". My understanding of the term immutable in the context of [[Java programming language|Java]] is that it means once you have a reference to the object its internal state will never change i.e. all fields (including private ones) can be declared final and all references that the object holds are themselves to immutable objects. This property, as far as I know, is not detected or enforced by the runtime and is not necessary for a local variable to be used in an anonymous inner class. The meaning of the keyword <tt>final</tt>, on the other hand, is that the value of the variable will never change which object it references (or will never change value if a primitive). It is this that is necessary for the anonymous inner type to make use of the variable so that the runtime can simply clone the primitive values and object references of final variables on the stack when instantiating the anonymous inner class.
Line 73 ⟶ 75:
----
==Closures and Python==
Why Python doesn't have closures:
|