comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Shared Generic Instance Code
Date: 1997/04/05
Date: 1997-04-05T00:00:00+00:00	[thread overview]
Message-ID: <E8585p.AE7@world.std.com> (raw)
In-Reply-To: 01bc4155$221728e0$2dfb82c1@xhv46.dial.pipex.com


In article <01bc4155$221728e0$2dfb82c1@xhv46.dial.pipex.com>,
Nick Roberts <Nick.Roberts@dial.pipex.com> wrote:
>Don't get confused between 'thunking' and mere indirect jumping/calling. A
>thunk is where a direct jump/call vector is replaced at runtime (and is
>thus a one-time thing per execution).

I don't think that's right.  I once spoke with Mike Woodger about this
(around 1992 or so).  He was involved in the original Algol 60, and I
think that's where the term "thunk" originated.  Algol 60 has
call-by-name, so if you pass a parameter to a procedure, let's say the
formal is X, and the actual is A[I], then "Y := X;" reevaluates the
value of A[I], and "X := Y" reevaluates the address of A[I].  Note that
I might have changed in the meantime, or might be a function call that
returns different results each time.  My understanding is that the
"thunk" was a *pair* of pointers-to-procedures, used to implement
call-by-name.  One procedure for getting the value, and one for getting
the address, of the actual parameter.

I believe the term "thunk" then mutated, to mean a *single* procedure,
when passed (implicitly) as a parameter, by a compiler, to implicitly
implement some feature of a programming language.  That's how *I* used
the term.  I admit that it's a bastardization of the original usage, as
explained to me by Woodger.

Your usage of the term, as poking the called-address of a call
instruction (or jump instruction) is not familiar to me.  Do you have
any references that use it that way?  Let's hear some etymology for your
use of the term.

Woodger was not sure where the term came from, but he thought it might
have been the past tense of "think", as in, the compiler is generating a
piece of code that does the "thinking" about where the actual parameter
is (two pieces of code, actually), so the "thinking has been thunk."  He
had another theory about it, which I've forgotten.  I could look it up,
but that would involve digging into deep stacks of paper long since
buried in the back corners of my office.  ;-)  I think it had to do with
the sound "thunk" which was made by something-or-other.

>...I think what you are suggesting is
>just passing in jump/call vectors, which would be jumped/called to by an
>indirect jump/call instruction. The vectors could change (by being passed
>in as hidden parameters) for each instantiation.

That's exactly what I'm suggesting (except that it would always be a
call, never a jump).  Is it wrong to call that a "thunk"?

Etymology is fun.  :-)

- Bob

P.S. It just occurred to me to look up "thunk" in "The Hacker's
Dictionary", edited by Eric Raymond, foreward and cartoons by Guy
Steele, Jr.  It says:

"1. A piece of coding which provides an address".  And various other
stuff which I don't feel like typing in.  Definitions 1 and 2 match what
I'm saying; definition 3 matches what you're saying.  And then it has a
"Historical note" that more-or-less matches what I said above about
past-tense-of-think, and also, the sound "thunk".  Interesting.  I guess
we're both right.




  reply	other threads:[~1997-04-05  0:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-01  0:00 Shared Generic Instance Code david scott gibson
1997-04-01  0:00 ` Robert A Duff
1997-04-02  0:00   ` Robert Dewar
1997-04-05  0:00   ` Nick Roberts
1997-04-05  0:00     ` Robert A Duff [this message]
1997-04-05  0:00       ` Nick Roberts
1997-04-06  0:00       ` Robert Dewar
1997-04-01  0:00 ` Pat Rogers
1997-04-01  0:00 ` Joel VanLaven
1997-04-01  0:00   ` Robert A Duff
1997-04-02  0:00     ` Robert Dewar
1997-04-02  0:00       ` Robert A Duff
1997-04-02  0:00   ` Robert Dewar
1997-04-02  0:00     ` Robert A Duff
1997-04-02  0:00 ` Jon S Anthony
1997-04-02  0:00   ` Robert A Duff
1997-04-03  0:00   ` Robert Dewar
1997-04-03  0:00 ` Bill Keen
1997-04-03  0:00   ` Robert Dewar
1997-04-04  0:00     ` Fergus Henderson
1997-04-04  0:00       ` Robert Dewar
1997-04-04  0:00   ` Robert A Duff
1997-04-03  0:00 ` Corey Minyard
1997-04-03  0:00 ` Jon S Anthony
1997-04-03  0:00   ` Robert Dewar
1997-04-04  0:00 ` Bill Keen
1997-04-04  0:00   ` Robert Dewar
1997-04-05  0:00     ` Tom Moran
1997-04-06  0:00       ` Nick Roberts
1997-04-07  0:00       ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox