[comp.lang.modula3] Problem with recursive type definition

pr@cl.cam.ac.uk (Peter Robinson) (01/24/91)

The following Modula-3 declaration:

| TYPE r = RECORD p: PROCEDURE (): r END;

causes the DEC SRC Modula-3 compiler (version 1.5, MIPS/Ultrix system)
to generate faulty C code:

| ...
| typedef struct { t2 _p; } t1; typedef void (*t2)(); 
| ...

where the use of t2 before its declaration is deemed to be a syntax error.

[I assume that the occurrence of r inside its expansion counts as being 
within a PROCEDURE type constructor, and so is legal code.  If r is the 
type of an argument to the procedure rather than its result, all is well.]

Curiously enough, putting a REF before the RECORD declaration does not help,
but the code for the analagous

| TYPE r = OBECT METHODS p (): r END;

is just fine.

- Peter Robinson.

P.S.  Sorry about this burst of trivia - I am just giving my Modula-3 
course to a new class of students with a different set of idiosyncracies in 
their programming styles.  Unfortunately, I am also a little nervous about