Path: utzoo!attcan!uunet!mcsun!ukc!cam-cl!news From: pr@cl.cam.ac.uk (Peter Robinson) Newsgroups: comp.lang.modula3 Subject: Problem with recursive type definition Summary: Faulty C code generated in some circumstances Message-ID: <1991Jan24.104353.2072@cl.cam.ac.uk> Date: 24 Jan 91 10:43:53 GMT Sender: news@cl.cam.ac.uk (The news facility) Organization: U of Cambridge Computer Lab, UK Lines: 29 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