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

1

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

Salzman answered 24/11, 2013 at 0:24 Comment(8)
type "lexical closure" into a search engine: en.wikipedia.org/wiki/Closure_(computer_science)Ultranationalism
Watch this video explain how to compiler implements clousures and what is a clousureWoodworker
@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.Salzman
@Woodworker Thanks...I know what closures are, and how c# implements them, but I am confused by the word "lexical"...Salzman
Close voter, please explain.Salzman
en.wikipedia.org/wiki/…Duff
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".Antipasto
@SaeedNeamati I agree. It seems overly complicated and misleading to me.Salzman
P
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.

Pyxis answered 24/11, 2013 at 0:42 Comment(1)
Ok...I guess I will dig more into the word lexical in regards to CS and lexical environments.Salzman

© 2022 - 2024 — McMap. All rights reserved.