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

Michael Greenberg michael.greenberg at pomona.edu
Fri Jul 31 12:49:24 EDT 2020


Hi Norman,

I don't have insight into the history, but a use of 'lexical' in the
POSIX shell standard shows that the confusion between "lexical" and
"syntactical" is pervasive and not just about binder scoping.

The `break` special builtin utility has the conventional meaning: break
from a loop. But consider the following program:

```
f() { break; }
while true; do f; done
```

Should `f` break from the outer loop or not? The standard refers to that
`break` as a "non-lexical break", using the phrase "lexically encloses"
<https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#break>. (It
turns out the behavior of non-lexically enclosing `break`s is
unspecified, and shells do different things. Good luck!)

I think "lexical" here (and in "lexical scoping") is meant to mean
"pertaining to the [bracketing structure of the] written concrete
syntax", even though that's not the dictionary meaning of the word
"lexical" (as you point out). It would make more sense to say
"syntactically enclosed", but... here we are.

Cheers,
Michael

On 2020-07-29 19:06:52, Norman Ramsey <nr at cs.tufts.edu> wrote:

> [ The Types Forum, https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.seas.upenn.edu%2Fmailman%2Flistinfo%2Ftypes-list&data=02%7C01%7Cmichael.greenberg%40pomona.edu%7C06a319f5bd674be8f12908d834add6be%7C817f590439044ee8b3a5a65d4746ff70%7C0%7C0%7C637317268526469223&sdata=OuVmPhQajwWm68NyfOzdblzXmXBwTdh1PwD1gS9628g%3D&reserved=0 ]
>
> This question might be off topic, but I hope not---there is a lot of
> knowledge here.  Why is "lexical scoping" called "lexical"?
> I'm used to "lexical" referring to properties that describe how
> concrete syntax is formed---what constitutes a comment, how characters
> are grouped into tokens, and that sort of thing.   The "lexical scope"
> used to give meaning to a closure seems more like a property of the
> syntax, not of the lexis.
>
> Is there another meaning of "lexical" that I don't know?
> Or some interesting history?
>
>
> Norman Ramsey
>
>
> ________________________________
>
> [EXTERNAL EMAIL] Exercise caution before clicking on links or opening attachments.


More information about the Types-list mailing list