Subject: Re: Alogl thunks [was Re: copying a vector? (Stalin 0.9?)]
From: (Rob Warnock)
Date: 6 Jan 2001 11:12:33 GMT
Newsgroups: comp.lang.scheme
Message-ID: <936uj1$lbm1n$>
Will Clinger - Sun Microsystems  <> wrote:
| Rob Warnock wrote:
| > Well, the ALGOL-10 compiler for the DEC PDP-10 (~1970) used thunks
| > (their term) for the call-by-name argument accessor code fragments
| > they passed around, and IIRC (though it's been ~30yr, so I could
| > have it slightly wrong), those thunks weren't "on the stack", nor
| > were they "activation records" -- they were fixed code fragments
| > whose addresses were passed as arguments.
| A pointer to code isn't enough to represent an Algol thunk.
| An Algol thunk is a closure (actually a pair of closures,
| as Rob pointed out).  That closure can be represented as a
| pointer to code along with a pointer to the (stack-allocated)
| environment.

But as I said in another reply, I don't think it permitted full
closure *values*, just procedure args, so a simple frame pointer
(dynamic link) in the subroutine calling sequence was enough to
allow the thunks to access the caller's lexical context.

| Aside from the stack allocation of environment structures,
| and the fact that two thunks were needed (the second to
| deal with the semantics of assignment in Algol), I don't
| see much difference between an Algol thunk and the thunks
| of current functional languages.

Well, since you couldn't return procedures as values[*], lexical
scopes could never survive their dynamic extent, so you didn't
need full environments as we know them today.


[*] Looking at <URL:
Algol60/>, the only types I can see a function can have are
"real", "integer", and "boolean" (though arguments can be of type
"procedure" or "<TYPE> procedure").

Rob Warnock, 31-2-510
SGI Network Engineering
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA