I've seen the term "lexical variable" a few times, mostly in the context of closures. Paul Graham uses the term in his books on Lisp referring to variables defined using the let expression.
I understand that lexical scoping is another name for static scoping. Is lexical variable just a variable that is visible in a program unit's referencing environment?
I hope to use this term to impress my friends and family this holiday season, can someone help me out?
A lexical variable is a variable that can only be referenced (by name) within its lexical scope. In other words, the scope of the variable is defined by the text of the program, not the dynamics of the program's execution. The variable and the value bound to it may have extent (life) beyond the lexical scope, e.g., if it is captured in a closure.
See this description of scope and extent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With