|Unintended polymorphism in Algol 60 email@example.com (John Cowan) (1995-06-23)|
|Re: Unintended polymorphism in Algol 60 firstname.lastname@example.org (1995-06-27)|
|From:||John Cowan <email@example.com>|
|Keywords:||algol60, polymorphism, question|
|Date:||Fri, 23 Jun 1995 04:04:54 GMT|
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
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
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 firstname.lastname@example.org
Return to the
Search the comp.compilers archives again.