6

I'm reading about C# and closure, various articles, Jon Skeet's awesome "C# in Depth" and I see statements like "C# and ruby implement lexical closure".

Why do the authors include the word "lexical"? Why not just say they "implement closure"?

What would it mean if it just implemented "closure", and not "lexical closure (if that's even possible)?

richard
  • 12,263
  • 23
  • 95
  • 151
  • type "lexical closure" into a search engine: https://en.wikipedia.org/wiki/Closure_(computer_science) – Mitch Wheat Nov 24 '13 at 00:26
  • Watch this [video](http://www.youtube.com/watch?v=ZQfhxD20v50) explain how to compiler implements clousures and what is a clousure – Tinwor Nov 24 '13 at 00:28
  • @MitchWheat I read that wiki article...it uses the word lexical a lot, but doesn't really tell me what it means...kinda like defining a word with itself. – richard Nov 24 '13 at 00:29
  • @Tinwor Thanks...I know what closures are, and how c# implements them, but I am confused by the word "lexical"... – richard Nov 24 '13 at 00:30
  • Close voter, please explain. – richard Nov 24 '13 at 00:30
  • 2
    http://en.wikipedia.org/wiki/Scope_(computer_science)#Lexical_scoping_vs._dynamic_scoping – Darren Kopp Nov 24 '13 at 00:42
  • IMHO, this is one of the worst nomenclatures I've ever seen in the real of software development. Lexical in every dictionary means "of words, related to words". So, what it can mean in a compound word like "lexical scope"? Even static scoping is not a good term. Based on what I've understood, I would prefer something like "contextual scope". – Saeed Neamati Dec 09 '13 at 16:23
  • @SaeedNeamati I agree. It seems overly complicated and misleading to me. – richard Dec 17 '13 at 21:37

1 Answers1

6

Lexical closure is just a more specific name for closure.

As you know, a closure allows a function to use variables from the scope where it was created, even if is executed from a different scope. Such a scope is also called a lexical environment, and that's where the term lexical comes from here.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005