Related articles |
---|
Call by name in Algol-60 RogerHA@aol.com (RogerHA) (1998-03-07) |
Re: Call by name in Algol-60 xxx@info.lv (1998-03-15) |
Re: Call by name in Algol-60 RogerHA@aol.com (RogerHA) (1998-03-18) |
Re: Call by name in Algol-60 lindsay-j@rmc.ca (John Lindsay) (1998-03-18) |
Re: Call by name in Algol-60 xxx@info.lv (1998-03-20) |
Jensen's device xxx@info.lv (1998-03-22) |
Re: Call by name in Algol-60 lindsay-j@rmc.ca (John Lindsay) (1998-03-24) |
Re: Jensen's device scott@basis.com (1998-03-24) |
Re: Jensen's device genew@vip.net (1998-03-30) |
Re: Jensen's device mslamm@olive.mscc.huji.ac.il (1998-03-30) |
Re: Jensen's device u-reddy@cs.uiuc.edu (Uday S. Reddy) (1998-03-30) |
[5 later articles] |
From: | xxx@info.lv |
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 |
Hello,
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 <RogerHA@aol.com> 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.
lindsay-j@rmc.ca 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]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.