🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.functional
12 messages
12 total messages Started by Tony Dekker Fri, 19 Apr 1991 06:42
miranda semantics
#869
Author: Tony Dekker
Date: Fri, 19 Apr 1991 06:42
137 lines
5415 bytes
Some Semantic Problems in Miranda (Re-Posting)
----------------------------------------------
The intended semantics of Miranda is that pairing is surjective, ie
_|_ = (_|_,_|_) is the least element of type (A,B) and that _|_ = \x._|_ is the
least element of type A->B.  Essentially, the semantics maps each type to
an ideal in a domain, or to a set of Lambda terms together with an equivalence
relation. For (A,B) we have a categorical product domain, or a set of Lambda
terms with Beta equality and p = (fst p,snd p).  For A->B we have a function
space, or a set of Lambda terms with Beta equality and extensionality. These
imply the two conditions with _|_.

However, the operational semantics is based on mapping Miranda terms to the
untyped Lazy Lambda Calculus (or rather, combinatory logic, which is almost the
same thing) which distinguishes _|_ from (_|_,_|_) = \x.x _|_ _|_ and _|_ from
\x._|_.

The attempted solution is to define ALL operations on type (A,B) in terms of
fst and snd so that _|_ and (_|_,_|_) aren't distinguished. As a result, 

          f (x,y) = 3

really defines a constant function.  SHOW functions also don't distinguish _|_
and (_|_,_|_).  Function application doesn't distinguish _|_ from \x._|_ and
neither do SHOW functions (all functions print as <function>, without
exception).

The problem is that the "convergence-testing" primitive seq defined such that:

     seq x y = _|_, x=_|_
             = y,   otherwise

distinguishes (_|_,_|_) from _|_ and \x._|_ from _|_.  This primitive is
inter-definable with:

     strict f x = _|_, x=_|_
                = f x, otherwise

since    strict f x = seq x (f x)    and    seq x y = strict (const y) x.
The function strict is necessary for synchronising input/output and for
defining foldl.

And this isn't easily fixed: if _|_ = (_|_,_|_) is the least element of type
(A,B) then eg:

   strict (const x) (y,z) = x,   y~=_|_ or z~=_|_
                          = _|_, y=z=_|_

which is an inherently parallel function! (It waits until one of y or z
terminates, and then kills the other one and returns x).

We can also distinguish _|_ from \x._|_ using polymorphic equality:
(\x._|_ = \x._|_) gives a runtime error while (_|_ = _|_) gives _|_.  However,
we could solve this by banning equality on functions, eg by having the type of
equality involve special type variables which cannot be instantiated to arrow
types. Perhaps we could restrict the applicability of strict and seq similarly.

If we really want to pretend that _|_ = (_|_,_|_), ie product is categorical
(coalesced) product, and _|_ = \x._|_, ie equality is extensional, we must
define a convergence-testing construct for each type, just as there is a SHOW
function for each type:

seq   x y = if x = x then y else b 
   num      where
            b = b

seq   [] y = y
   [A]
seq   (h:t) y = y
   [A]

seq   (InL x) y = y
   A+B
seq   (InR x) y = y
   A+B

seq     x y = if por (seq (fst x) True) (seq (snd x) True) then y else b
   (A,B)                 A                  B
              where
              b = b

Here por is "parallel or". Plotkin in his classical paper on PCF and full
abstraction defines two inherently parallel operations:

pcond :: bool -> * -> * -> *
pcond x y z = y,  x = True          || this condition is a semantic one
            = z,  x = False         || not Miranda code
            = y,  x = _|_  and  y = z

exists :: (nat -> bool) -> bool
exists f = False,  f _|_ = False
         = True,   f 0 = True  or  f 1 = True  or  ...

The idea is (exists f) approximates the predicate calculus statement  E x.f x
Using these operations,

por x y = pcond x True y

We can also define a version of seq for functions, at least those defined
on nat.  If  

f :: nat -> A

we define 

f' :: nat -> bool
f' n = seq (f n) True
          A

seq      f x = if exists f' then x else b
   nat->A
               where
               b = b

So the question of convergence-testing is completely tied up with the question
of full abstraction, somehow.

The questions I'd like to ask are:
- What do we really intend strictness on pairs and functions to mean?
- Can we implement what we intend?
- What use are such functions?
- Does HASKELL have these problems?
- Is this an argument for adding por to Miranda?
- What exactly is the relationship between convergence-testing and full
  abstraction?
- How does this affect strictness analysis?

For example, \f.\x.f x      is strict on f
             \x.(x,x)       is strict on x
             \x.(x,_|_)     is strict on x
             \x.(x,3)       is NOT strict on x
             \(x,y).x = fst is strict on (x,y)

Clearly \x.(M,N) is strict on x if \x.M and \x.N are both strict on x.

Any ideas anyone?
                    Tony Dekker
thunk's
#870
Author: lavinus
Date: Mon, 22 Apr 1991 23:04
16 lines
1095 bytes
Hi out there!

I have a question that has been nagging me for quite some time: why do we
call closures "thunk"s?  I mean, where did that word come from?  The only
two theories I've heard, neither with *any* supporting evidence, are that
it is an anagram for Knuth, and that perhaps it is a facetious past tense
of "think".  Anyone know??

Thanks,

Joe
--
_________________________________ \ ___________________________________
 Joseph W. Lavinus, Virginia Tech  \   email: lavinus@csgrad.cs.vt.edu
 1204-A University Terrace         /\  phone: (703) 552-0241
 Blacksburg, VA  24060            /  \        (703) 231-5853
Re: thunk's
#871
Author: Pete Harlan
Date: Tue, 23 Apr 1991 01:54
17 lines
1232 bytes
>I have a question that has been nagging me for quite some time: why do we
>call closures "thunk"s?  I mean, where did that word come from?  The only
>two theories I've heard, neither with *any* supporting evidence, are that
>it is an anagram for Knuth, and that perhaps it is a facetious past tense
>of "think".  Anyone know??

"The word _thunk_ derives from the implementation of call-by-name in
Algol 60.  We do not know the origin of this name, but we have heard
that it refers to the sound made by data when pushed onto the stack in
a running Algol system."

  ---Abelson and Sussman, "Structure and Interpretation of Computer Programs"

Well, there you are! :-)

Pete Harlan
harlan@copper.ucs.indiana.edu
Re: thunk's
#872
Author: Raja Sooriamurthi
Date: Tue, 23 Apr 1991 03:05
30 lines
1684 bytes
>>I have a question that has been nagging me for quite some time: why do we
>>call closures "thunk"s?  I mean, where did that word come from?  The only
>>two theories I've heard, neither with *any* supporting evidence, are that
>>it is an anagram for Knuth, and that perhaps it is a facetious past tense
>>of "think".  Anyone know??

>"The word _thunk_ derives from the implementation of call-by-name in
>Algol 60.  We do not know the origin of this name, but we have heard
>that it refers to the sound made by data when pushed onto the stack in
>a running Algol system."

>  ---Abelson and Sussman, "Structure and Interpretation of Computer Programs"

To quote another source: 

	"The implementation of call-by-name is discusses by Ingerman
who introduces the term thunk to refer to this type of closure
[Ingerman 61]. (The term _thunk_ was presumably a reference to the
'noise' that a static chain pointer makes as it moves within
activation records)" 

			-Horowitz "Fundamentals of Programming Languages"

[Ingerman 61] Ingerman, P. "Thunks" Comm. ACM, 4,1,1961 55-58

(looks like this is where it originated)

-Raja
raja@cs.indiana.edu
Re: thunk's
#880
Author: S Matthews
Date: Tue, 23 Apr 1991 09:07
15 lines
1032 bytes
lavinus@csgrad.cs.vt.edu writes:

>I have a question that has been nagging me for quite some time: why do we
>call closures "thunk"s?  I mean, where did that word come from?  The only

Did this not come from work on implementing call by name in Algol 60,
where the stack pointer was imagined to go `thunk!' as it jumped from
one environment to another. 

Sean

-- 
Sean Matthews                        80 South Bridge, Edinburgh, UK 
Dept. of Artificial Intelligence     +44 (0) 31 650 2722
University of Edinburgh              sean@castle.ed.ac.uk
Re: thunk's
#875
Author: Peter Wentworth
Date: Tue, 23 Apr 1991 09:16
15 lines
1313 bytes
In <1151@creatures.cs.vt.edu> lavinus@csgrad.cs.vt.edu writes:
>I have a question that has been nagging me for quite some time: why do we
>call closures "thunk"s?  I mean, where did that word come from?  The only
>two theories I've heard, neither with *any* supporting evidence, are that
>it is an anagram for Knuth, and that perhaps it is a facetious past tense
>of "think".  Anyone know??

In Gries' book on compiler construction he says its because of the 
noise that the base pointer makes as you drop it back to the previous
context. 'Thunk!' (It was a long time ago when we used the book ... hope I've
remembered it right ...!)
Pete
--
EP Wentworth - Dept. of Computer Science - Rhodes University - Grahamstown.
cspw@alpha.ru.ac.za  
Re: thunk's
#874
Author: Markku Sakkinen
Date: Tue, 23 Apr 1991 09:41
45 lines
2500 bytes
In article <harlan.672371659@copper> harlan@copper.ucs.indiana.edu (Pete Harlan) writes:
>>I have a question that has been nagging me for quite some time: why do we
>>call closures "thunk"s?  I mean, where did that word come from?  The only
>>two theories I've heard, neither with *any* supporting evidence, are that
>>it is an anagram for Knuth, and that perhaps it is a facetious past tense
>>of "think".  Anyone know??

>"The word _thunk_ derives from the implementation of call-by-name in
>Algol 60.  We do not know the origin of this name, but we have heard
>that it refers to the sound made by data when pushed onto the stack in
>a running Algol system."
>
>  ---Abelson and Sussman, "Structure and Interpretation of Computer Programs"
>
>Well, there you are! :-)
>
>Pete Harlan
>harlan@copper.ucs.indiana.edu

I have always somehow thought that it is a Lewis Carroll -style
combination of 'think' and 'chunk', which probably goes well with
the effort of implementing call-by-name.  The onomatopoietic
interpretation of Abelson and Sussman was obviously made with
tongue in cheek - although perhaps with a tiny, subconscious
resentment toward the most important programming-language
development in the history of computing.
One could define in the same manner:

'clunk' -- the rattling noise of garbage cans caused by garbage
           collection in a running Lisp system

The anagram theory does not sound likely:  I suppose Knuth was not
very famous yet when the term was adopted.

The chapters on Algol in the proceedings of the ACM History of
Programming Languages conference (1978?) might shed some light on this.
The proceedings appeared as a special issue of SIGPLAN Notices.

Markku Sakkinen
Department of Computer Science and Information Systems
University of Jyvaskyla (a's with umlauts)
PL 35
SF-40351 Jyvaskyla (umlauts again)
Finland
          SAKKINEN@FINJYU.bitnet (alternative network address)
Re: thunk's
#879
Author: D.A.Turner
Date: Tue, 23 Apr 1991 10:17
20 lines
1472 bytes
In article <1151@creatures.cs.vt.edu> lavinus@csgrad.cs.vt.edu () writes:
>Hi out there!
>
>I have a question that has been nagging me for quite some time: why do we
>call closures "thunk"s?  I mean, where did that word come from?

I can throw some light on the origin of the word "thunk".  It was in use
around  1960  amongst  school-children  in London (maybe elsewhere but I
have no evidence) as slang for day-dream or fantasy.  Eg.  "You look far
away, are you having a thunk?" In this context I always assumed it to be
a facetious past tense for "think".

The  word  entered  computer  science   not   long   after,   when   the
mini-procedures   needed   to   implement  Algol-60's  call-by-name  got
christened "thunks" (I think by Randell and Russell).  Its use today for
closures obviously descends from that.  Whether Randell and Russell took
the word from the use mentioned in the previous para I do not know.

David Turner
(University of Kent)
Re: thunk's
#876
Author: Peter Sestoft
Date: Tue, 23 Apr 1991 16:35
43 lines
2525 bytes
raja@copper.ucs.indiana.edu (Raja Sooriamurthi) writes:

>>>I have a question that has been nagging me for quite some time: why do we
>>>call closures "thunk"s?  I mean, where did that word come from?  The only
>>>two theories I've heard, neither with *any* supporting evidence, are that
>>>it is an anagram for Knuth, and that perhaps it is a facetious past tense
>>>of "think".  Anyone know??

>>"The word _thunk_ derives from the implementation of call-by-name in
>>Algol 60.  We do not know the origin of this name, but we have heard
>>that it refers to the sound made by data when pushed onto the stack in
>>a running Algol system."

>>  ---Abelson and Sussman, "Structure and Interpretation of Computer Programs"

>To quote another source: 

>	"The implementation of call-by-name is discusses by Ingerman
>who introduces the term thunk to refer to this type of closure
>[Ingerman 61]. (The term _thunk_ was presumably a reference to the
>'noise' that a static chain pointer makes as it moves within
>activation records)" 

>			-Horowitz "Fundamentals of Programming Languages"

>[Ingerman 61] Ingerman, P. "Thunks" Comm. ACM, 4,1,1961 55-58

There is little doubt that the term "thunk" originates in P.Z.
Ingerman's paper, but the paper is silent as to its etymology.  

The pseudo-onomatopoetic explanations for "thunk2 offered above are
clearly not to be taken seriously.  By the way, the paper contains
other examples of linguistic creativity: one example procedure is
called "glub", another "george"; and a procedure (due to Sattley) for
allocating arrays is called the FUSBUDGET mechanism.

As far as I recall, Peter Naur described the word as "foolish American
slang" in a lecture --- or maybe it was the "dope vector" he derided.

-- 
Peter Sestoft  *  sestoft@diku.dk   *   DIKU,  Department of Computer Science
University of Copenhagen, Universitetsparken 1, DK-2100 Copenhagen O, Denmark
Tel: +45 31 39 64 66  *  Direct: +45 31 39 33 11/406  *  Fax: +45 31 39 02 21
Re: thunk's
#877
Author: Bill Kinnersley
Date: Tue, 23 Apr 1991 19:26
89 lines
4799 bytes
In article <1151@creatures.cs.vt.edu>, lavinus@csgrad.cs.vt.edu writes:
> Hi out there!
> 
> I have a question that has been nagging me for quite some time: why do we
> call closures "thunk"s?  I mean, where did that word come from?  The only
> two theories I've heard, neither with *any* supporting evidence, are that
> it is an anagram for Knuth, and that perhaps it is a facetious past tense
> of "think".  Anyone know??
> 

The following AUTHORITATIVE answer was recently posted to 
alt.folklore.computers:

------------

Newsgroups: alt.folklore.computers
Subject: THUNKS
Message-ID: <QbxsiCu00VsaA0oms6@andrew.cmu.edu>
From: jn11+@andrew.cmu.edu (Joseph M. Newcomer)
Date: 1 Apr 91 19:35:42 GMT
Organization: Carnegie Mellon, Pittsburgh, PA

[...]

Back around 2.6, I sent a note to Eric saying that the definition of "thunks"
was not quite accurate.  He had included the explanation "...the sound of
the result hitting the stack" whereas I remembered it as "...the sound of
the result hitting the accumulator".  While he held that his two correspondents
were absolutely certain they were right, I was absolutely certain that
they were wrong.  Machines in 1960 didn't HAVE stacks; they
had software implementations of stacks, and no sane programmer would
have developed a result in the accumulator, pushed it onto the stack, and
then have to pop it off the stack back to the accumulator; this was too
expensive.  Besides, I pointed out that the sound of a result hitting a
stack is more like a "whoosh" than a "thunk".

The "stack" version remained, and I was certain this was wrong.  I called or
sent mail to several people trying to find their memory of the evolution
of this
term and to try to locate Peter Z. Ingerman.  Brian Randell claimed that he
found the name unacceptable, and in his book ("Algol-60 implementation")
they referred to the construct as "implicit subroutine".  Art Evans said
he thought the term came about because the result had "already been
thunk about".  Nobody else had any leads.  Gwen Bell at the Computer
Museum said that ACM probably had Peter's address as he had been an
editor of Computing Reviews until a few years ago.

This morning I called ACM headquarters, got Peter's address, and
directory assistance gave me his phone number.  I introduced myself and
told about both my interest in computer history and my desire to know
the etymology of the word "thunks".  He asked "do you /really/ want to
know?"  After being convinced I was serious, he gave the explanation. 
The following transcript is from my notes which I tried to make
reasonably complete.  I asked Peter for permission to post this to
a.f.c. and he granted it.  Any errors, mis-spellings of peoples' names,
or omissions are my fault.

"Ned Irons, Wally Feuerzeig, Kirk Sampley, Herb Tanner and myself (and I
think there were a couple of others, but I'm not sure) got together to
decide how Algol call-by-name worked.  We ended up in Princeton (where
Ned Irons worked) and we co-opted a classroom for our discussion.  We
tossed the thing back and forth and worked out the idea that we had to
do it differently if the parameter was a label, a variable, an
expression, an array, etc.   By the time we were done it was 2 in the
morning (you understand how it gets to be 2 in the morning...and that is
possibly the most significant part of this story) and it suddenly dawned
on us, more or less simultaneously, that all of the thinking about this
-- that it was an array, label, etc., -- could be done at compile time. 
This meant that all of the thinking was already done.  At 2 in the
morning the past tense of "think" is "thunk", and that's how the name
came about.

"Interestingly enough, Andrei Yershov [of the Soviet Academy of
Sciences, and, alas, the late Andrei Yershov now; one of the significant
pioneers of the field...-jmn] asked me this same question at a
conference in Warsaw a few years ago.  This was after he had introduced
the word "thunk" into the Russian language as "methoda sankov" [the
phonetic rendering; spelling is Peter's English transliteration...-jmn],
which translates as "the method of thunks"."

Of the responses I got, Art's was the correct one.

[...]

						joe
------------

-- 
--Bill Kinnersley
Thunk -- the real scoop
#878
Author: Jonathan A. Chandross
Date: Tue, 23 Apr 1991 21:06
83 lines
4647 bytes
There was a discussion of thunks a few weeks back on alt.folklore.computers.
Following is an excerpt from a posting by Joseph Newcomer on the real scoop
on thunks.

------------------- Begin Quote ----

Joseph M. Newcomer
Mon Apr  1 14:35:42 1991
jn11+@andrew.cmu.edu
Carnegie Mellon
Pittsburgh, PA

Here's a REAL piece of folklore (dammit, stop the Jargon bandwidth
debates; they may not consume much network bandwidth but they
consume MY bandwidth).  This is jargon-related.

Let me start with some recent history...

Back around 2.6, I sent a note to Eric saying that the definition of "thunks"
was not quite accurate.  He had included the explanation "...the sound of
the result hitting the stack" whereas I remembered it as "...the sound of
the result hitting the accumulator".  While he held that his two correspondents
were absolutely certain they were right, I was absolutely certain that
they were wrong.  Machines in 1960 didn't HAVE stacks; they
had software implementations of stacks, and no sane programmer would
have developed a result in the accumulator, pushed it onto the stack, and
then have to pop it off the stack back to the accumulator; this was too
expensive.  Besides, I pointed out that the sound of a result hitting a
stack is more like a "whoosh" than a "thunk".

The "stack" version remained, and I was certain this was wrong.  I called or
sent mail to several people trying to find their memory of the evolution
of this
term and to try to locate Peter Z. Ingerman.  Brian Randell claimed that he
found the name unacceptable, and in his book ("Algol-60 implementation")
they referred to the construct as "implicit subroutine".  Art Evans said
he thought the term came about because the result had "already been
thunk about".  Nobody else had any leads.  Gwen Bell at the Computer
Museum said that ACM probably had Peter's address as he had been an
editor of Computing Reviews until a few years ago.

This morning I called ACM headquarters, got Peter's address, and
directory assistance gave me his phone number.  I introduced myself and
told about both my interest in computer history and my desire to know
the etymology of the word "thunks".  He asked "do you /really/ want to
know?"  After being convinced I was serious, he gave the explanation. 
The following transcript is from my notes which I tried to make
reasonably complete.  I asked Peter for permission to post this to
a.f.c. and he granted it.  Any errors, mis-spellings of peoples' names,
or omissions are my fault.

"Ned Irons, Wally Feuerzeig, Kirk Sampley, Herb Tanner and myself (and I
think there were a couple of others, but I'm not sure) got together to
decide how Algol call-by-name worked.  We ended up in Princeton (where
Ned Irons worked) and we co-opted a classroom for our discussion.  We
tossed the thing back and forth and worked out the idea that we had to
do it differently if the parameter was a label, a variable, an
expression, an array, etc.   By the time we were done it was 2 in the
morning (you understand how it gets to be 2 in the morning...and that is
possibly the most significant part of this story) and it suddenly dawned
on us, more or less simultaneously, that all of the thinking about this
-- that it was an array, label, etc., -- could be done at compile time. 
This meant that all of the thinking was already done.  At 2 in the
morning the past tense of "think" is "thunk", and that's how the name
came about.

"Interestingly enough, Andrei Yershov [of the Soviet Academy of
Sciences, and, alas, the late Andrei Yershov now; one of the significant
pioneers of the field...-jmn] asked me this same question at a
conference in Warsaw a few years ago.  This was after he had introduced
the word "thunk" into the Russian language as "methoda sankov" [the
phonetic rendering; spelling is Peter's English transliteration...-jmn],
which translates as "the method of thunks"."

Of the responses I got, Art's was the correct one.

----------- End Quote ----



Jonathan A. Chandross
Internet: jac@paul.rutgers.edu
UUCP: rutgers!paul.rutgers.edu!jac
Re: thunk's
#884
Author: Dipankar Gupta
Date: Fri, 26 Apr 1991 11:59
16 lines
1114 bytes
In article <1151@creatures.cs.vt.edu> lavinus@csgrad.cs.vt.edu () writes:
>Hi out there!
>
>I have a question that has been nagging me for quite some time: why do we
>call closures "thunk"s?  I mean, where did that word come from?  The only
>two theories I've heard, neither with *any* supporting evidence, are that
>it is an anagram for Knuth, and that perhaps it is a facetious past tense
>of "think".  Anyone know??
>
Weren't the "call-by-name" params in Algol-60 called thunks?

Dipankar
Hewlett-Packard India Software Operation
Bangalore, INDIA

Gupta_D@apollo.hp.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads