Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "lexical" mean in the statement "C# implements lexical closure"?

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)?

like image 213
richard Avatar asked Nov 24 '13 00:11

richard


1 Answers

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.

like image 89
Guffa Avatar answered Oct 28 '22 16:10

Guffa