Policies for handling symbols leaking out of a lexical scope Suppose it's possible for a symbol to escape the scope in which it is defined. What are considered the possible policies for handling that? I mean possible in the sense of what choices of language design that could be implemented -- different choices yield languages which differ in this respect.

For example, it's conceivable that two lexical scopes might each contain a symbol named "x". If these symbols escape from their respective scopes, what can we say about that? I can see three possibilities: all symbols named "x" are the same, so the symbol leaked out of the first scope is the same as that leaked out of the second; or each symbol named "x" is actually a distinct symbol, so the leaked symbols are not the same; or when a symbol escapes from its scope, something about that lexical context is carried along with the symbol, so that the result of the leakage is not a symbol but a more complex object representing the lexical context or environment and the symbol together. No doubt there are other possibilities.

I know Common Lisp implements the first policy -- (eq (let (x) 'x) (let (x) 'x)) yields T. I think Scheme does too. I don't know enough about other languages to say what might happen. I'm not aware of languages which implement the second or third ideas, but, as I was saying, my awareness is limited, and I would be interested to hear about any such languages.

I'm sure this is a topic which is well-known in the programming languages field, but through some reading and searching I haven't found it yet.
Your (let (x) 'x) will just return the atom x, and obviously all of those are the same. That you define variables called x (and give them no value whatsoever, and never use them) is just confusing the issue. I.e., your code is a roundabout way to write (eq 'x 'x).

How could a name "escape" from a lexical scope? The scope is precisely where the name has a particular meaning, an "escape" would just expand that scope somehow.

E.g. in Steelbank Common Lisp:

* (let (x) 'x)
; in: LET (X)
;     (LET (X)
;       'X)
; 
; caught STYLE-WARNING:
;   The variable X is defined but never used.
; 
; compilation unit finished
;   caught 1 STYLE-WARNING condition
X


enter code here