Robert A Duff wrote:
> In article <34ce2518.0@rcfnews.cs.umass.edu>,
> Robin Popplestone <pop@cs.umass.edu> wrote:
> >From the implementor's point of view, you don't just stumble into
> >call-by-name, because you've got to work at it. Indeed the nomenclature of
> >the early Algol implementors, who talked of "thunks" has survived to this
> >day in the functional language community for lazy evaluation. Nobody else
> >talks of "thunks" or thinks about them either. ...
>
> Not sure what "else" refers to in "Nobody else...". If you mean,
> "Nobody else than the functional language community", then that's not
> quite true. At least some compiler writers (for non-functional
> languages like Ada, for example) use the term "thunk" to refer to any
> compiler-generated procedure that doesn't directly correspond to a
> source-code-level procedure. This doesn't exactly match the Algol term,
> which was really a *pair* of compiler-generated procedures.
>
The term thunk seems to mean several different things as expressed here. In the
Microsoft Windows world the term thunk refers to the fixup needed to jump to
(call) a function in a dynamic link library (DLL). (i.e. I reserve a spot for
the address of the function to jump to, but the address is resolved and updated
at runtime by the loader.)
I pulled out my handy Hacker's jargon file and found the following:
:thunk: /thuhnk/ /n./ 1. "A piece of coding which provides
an address", according to P. Z. Ingerman, who invented thunks in
1961 as a way of binding actual parameters to their formal
definitions in Algol-60 procedure calls. If a procedure is called
with an expression in the place of a formal parameter, the compiler
generates a thunk which computes the expression and leaves the
address of the result in some standard location. 2. Later
generalized into: an expression, frozen together with its
environment, for later evaluation if and when needed (similar to
what in techspeak is called a `closure'). The process of
unfreezing these thunks is called `forcing'. 3. A
{stubroutine}, in an overlay programming environment, that loads
and jumps to the correct overlay. Compare {trampoline}.
4. People and activities scheduled in a thunklike manner. "It
occurred to me the other day that I am rather accurately modeled by
a thunk -- I frequently need to be forced to completion." ---
paraphrased from a {plan file}.
Historical note: There are a couple of onomatopoeic myths
circulating about the origin of this term. The most common is that
it is the sound made by data hitting the stack; another holds that
the sound is that of the data hitting an accumulator. Yet another
suggests that it is the sound of the expression being unfrozen at
argument-evaluation time. In fact, according to the inventors, it
was coined after they realized (in the wee hours after hours of
discussion) that the type of an argument in Algol-60 could be
figured out in advance with a little compile-time thought,
simplifying the evaluation machinery. In other words, it had
`already been thought of'; thus it was christened a `thunk',
which is "the past tense of `think' at two in the morning".
--
Keith
kbreinho@bsquare.com
----------------------------------------
"No Life ever grows great until it is focused, dedicated and disciplined."
-Henry Emerson Fosdick
|