Re: Call by name in Algol-60
20 Mar 1998 11:42:39 -0500

          From comp.compilers

Related articles
Call by name in Algol-60 (RogerHA) (1998-03-07)
Re: Call by name in Algol-60 (1998-03-15)
Re: Call by name in Algol-60 (RogerHA) (1998-03-18)
Re: Call by name in Algol-60 (John Lindsay) (1998-03-18)
Re: Call by name in Algol-60 (1998-03-20)
Jensen's device (1998-03-22)
Re: Call by name in Algol-60 (John Lindsay) (1998-03-24)
Re: Jensen's device (1998-03-24)
Re: Jensen's device (1998-03-30)
Re: Jensen's device (1998-03-30)
Re: Jensen's device (Uday S. Reddy) (1998-03-30)
[5 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
Date: 20 Mar 1998 11:42:39 -0500
Organization: Deja News - The Leader in Internet Discussion
References: 98-03-074 98-03-124 98-03-160
Keywords: algol60, summary, comment


I would like to thank all the people who responded to my article. I
feel that now I understand call-by-name implementation much better. I
have gone through many books about compiler writing and programming
language design, and nowhere I was able to find such a good
explanation of thunk mechanism. Your explanation was very helpful,
thank you very much indeed. It was my fault, perhaps, that I haven't
explicitly stated one thing and thus caused responses like these:

RogerHA <> wrote:
> You can do it by returning an address, but this is not enough by
> itself, as the moderator said. It is not possible for the compiler to
> know whether or not the address can be used meaningfully. You must
> have some way of checking this at run time. I suggested separate
> thunks, but other ways are possible. You could use the same thunk but
> with a parameter, to indicate whether a fetch from or assignment to
> the calculated address is about to be done. The address could be
> marked or known from its value whether it is a temporary variable or
> one declared by the programmer. If the response to my posting on
> another thread is anything to go by, you will get some more
> suggestions, there is nothing new in any of this. wrote:
> > If, in the case of an actual parameter being an expression, the second
> > thunk is there only to cause a run-time exception, wouldn't it be
> > better to check this already in the compiling time ?
> Sometimes the check is effectively impossible, especially if the
> actual parameter is passed down through a couple of layers of
> procedure calls. It may happen in a program that in those cases where
> an expression is passed as an actual parameter, the formal parameter
> is never assigned to, but in some of the cases where the actual
> parameter is a variable or array element, the formal parameter is
> assigned too.

My question was, in fact, not about how thunks were implemented in
Algol-60, but rather how they should be implemented, if someone was
going to extend a modern language, like Pascal or Modula-2, with this
type of parameter passing. The languages mentioned above both have
strong type checking across the boundaries of compilation units. It is
possible to check the problem mentioned above in the time of
compilation, not in run time. There are no implicit type conversions
permitted in these languages, so, there is no need for run time type
checks too. In Algol-60 type checking between compilation units was
nonexistent (as far as I know), and all things you said are absolutely
correct in case of Algol.

                                                    Best wishes - Andrejs.
[Remember that call by name was a mistake. The Algol60 was trying to write
an elegant definition of call by reference and inadvertently created call
by name. Nobody realized it until the paper on Jensen's device. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.