[TYPES] what is "lexical" about "lexical scoping"?

Hendrik Boom hendrik at topoi.pooq.com
Mon Aug 3 19:19:50 EDT 2020


On Sun, Aug 02, 2020 at 11:34:14PM -0400, Stefan Monnier wrote:
> [ The Types Forum, http://lists.seas.upenn.edu/mailman/listinfo/types-list ]
> 
> > 2. "of or relating to a lexicon or to lexicography"
> >
> > That is the meaning I would associate with the phrase "lexical
> > scoping". As I understand lexical scoping, a scope is a dictionary or
> > lexicon, basically a map from identifiers of the concrete syntax to
> > binding sites of the abstract syntax. This dictionary is updated
> > during parsing. Perhaps "lexical" refers to the fact that the meaning
> > of the identifier is looked up in this (static) lexicon, as opposed to
> > determined dynamically at runtime?
> 
> I don't really buy that explanation: the implementation of dynamic
> scoping also uses a "dictionary" where variables are looked up.
> The rules for which dictionary to use when is just a bit different from
> those of static scoping, but the lookup of variables in a lexicon is
> common to both scoping rules.

Yes, both scoping rules use a lexicon.  What makes dynamic scoping 
dynamic is that the lexicon is used at run time, and can even be 
different from one call of a function to another.

I'm speaking the (in my mind execrable) habit of letting the variables 
available at the caller be the ones used in the callee.

-- hendrik


More information about the Types-list mailing list