3 ms·
What name does it have AFTER it has been returned from the environment that it was created in? If you have 5 different things that are all different but suppos
by btilly 14y ago
What name does it have AFTER it has been returned from the environment that it was created in?
If you have 5 different things that are all different but supposedly have the same name, what does it mean to have a name?
- adrusi 14y ago"anonymous function" is a term that refers to a syntax for declaring a function without immediately naming it. A function can't "become" anonymous at runtime by leaving the environment in which it was created. "lexical closure" is a term used to describe the way that functions behave at runtime. A lexical closure can be used as a first class value, and retains the scope that it was created in, as opposed to adopting the scope in which is is called. Example: def foo(bar): a = 2 bar() a = 5 def baz(): print a will print "5" not "2". but note that `baz` is not anonymous because being anonymous is a syntactic quality and in the source code, `baz` is named in the same operation as it is declared.