| Related articles |
|---|
| From: | Kaz Kylheku <217-679-0842@kylheku.com> |
| Newsgroups: | comp.compilers |
| Date: | Fri, 2 Mar 2018 00:38:30 +0000 (UTC) |
| Organization: | Aioe.org NNTP Server |
| References: | 18-02-009 18-02-012 18-02-016 18-02-018 18-02-023 18-02-029 18-02-032 18-02-034 18-03-002 18-03-006 |
| Injection-Info: | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="2038"; mail-complaints-to="abuse@iecc.com" |
| Keywords: | code, design, comment |
| Posted-Date: | 01 Mar 2018 21:37:29 EST |
On 2018-03-01, Kaz Kylheku <217-679-0842@kylheku.com> wrote:
> John:
> [A display is an array of pointers to the frames of the enclosing
> scopes. You can access any variable in an enclosing frame by
> indirecting through the frame's entry in the current display and then
> indexing. This is for languges like Algol and Pascal, not Lisp. I
This is absolutely relevant to Lisp dialects with lexical scoping,
like Common Lisp and Scheme (or anything worth its salt, really).
There are no first-class functions without lexical scoping.
Structure and Interpretation of Computer Programs (SICP) discusses
something similar to displays in "5.5.6 Lexical Addressing":
https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-35.html#%_sec_5.5.6
"We can exploit this fact by inventing a new kind of variable-lookup
operation, lexical-address-lookup, that takes as arguments an
environment and a lexical address that consists of two numbers: a frame
number, which specifies how many frames to pass over, and a displacement
number, which specifies how many variables to pass over in that frame.
Lexical-address-lookup will produce the value of the variable stored at
that lexical address relative to the current environment."
The focus of that section is eliminating the run-time search which
actually finds a name by symbol matching, with numeric indexing.
However, if we can "pass over" the frames by indexing through a vector
of them, then we have a display. We can also directly index into the
frame by also representing it as a vector, so we don't have to
"pass over" n-1 variables to get to the n-th one.
[I was thinking of closures when I said not Lisp. I suppose you could
use displays and garbage collect them but I haven't really thought
about the implications. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.