Unintended polymorphism in Algol 60

John Cowan <cowan@locke.ccil.org>
Fri, 23 Jun 1995 04:04:54 GMT

          From comp.compilers

Related articles
Unintended polymorphism in Algol 60 cowan@locke.ccil.org (John Cowan) (1995-06-23)
Re: Unintended polymorphism in Algol 60 gvcormac@plg.uwaterloo.ca (1995-06-27)
| List of all articles for this month |

Newsgroups: comp.compilers
From: John Cowan <cowan@locke.ccil.org>
Keywords: algol60, polymorphism, question
Organization: Compilers Central
Date: Fri, 23 Jun 1995 04:04:54 GMT
Status: RO

I am in the process of implementing a compiler for Algol 60. For portability
and simplicity, the target language will be Gnu C, which (unlike Standard C)
already contains many of the needed constructs. However, I have run into
two oddball properties of Algol 60 (per the Revised Report) that I
need guidance on. Anyone who has used or implemented Algol 60, please
fill me in!

1) Some Algol 60 procedures seem to be polymorphic. Consider:

'procedure' foo(a, b, c) 'begin'
a := b + c
'real' r;
'integer' i;
foo(i, 3, 4);
foo(r, 3, 4);
foo(i, 3.5, 4);
foo(r, 3.5, 4);
foo(i, 3, 4.5);
foo(r, 3, 4.5);
foo(i, 3.5, 4.5);
foo(r, 3.5, 4.5)

This program seems to be perfectly valid, since there are no type
declarations for the formal parameters a, b, c. However, it's not clear how
to compile 'foo' into a single function, since we don't know how to cast
the variables so as to get the right implementation of addition.
(This causes a problem because the arithmetic operators are themselves
polymorphic, and in this program the polymorphism can't be resolved at
compile time.)

Furthermore, the standard implementation of call-by-name variable parameters
as parameterless procedures returning a pointer to the real data doesn't
work, because the caller of the thunk doesn't know whether to write
real bits or integer bits at the address provided.

2) A parameter of type procedure in Algol 60 doesn't have any type or
calling-convention information about the parameters. How does one know
whether to supply thunks or values, and what type of values? Since there
are no variables of procedure type, thank Ghu, a complete flow trace is
possible, but is this really necessary?

I will be most appreciative for any help that anyone can provide.
Anti-A60 or anti-Gnu flames to /dev/null.

John Cowan cowan@ccil.org

Post a followup to this message

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