Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbatt!ihnp4!inuxc!pur-ee!j.cc.purdue.edu!k.cc.purdue.edu!afd From: afd@k.cc.purdue.edu.UUCP Newsgroups: comp.lang.modula2 Subject: one pass, ADT initialization problems. Message-ID: <1747@k.cc.purdue.edu> Date: Mon, 2-Feb-87 12:05:26 EST Article-I.D.: k.1747 Posted: Mon Feb 2 12:05:26 1987 Date-Received: Thu, 5-Feb-87 04:31:26 EST Distribution: net Organization: Purdue University Computing Center Lines: 28 Keywords: one pass, ADT (* This is reposted; my apologies to anyone who receives this twice. *) First, I recall from some time ago a discussion on forward references in a one pass Modula-2 compiler being impossible. Last semester we implemented Aho, Sethi, and Ullman's unification algorithm with type variables (pg. 366, 376) and it worked quite well. I see no problem in implementing forward references for types or procedures in a one pass Modula-2 compiler. Second, concerns the initialization problems with Modula-2 ADTs. When a procedure is called with an uninitialized ADT, a test for undefined is impossible, and a simple test for nil is obviously insufficient. One solution is to maintain a list of pointers to initialized variables of an opaquely exported type. A simple test at the beginning of each procedure which accesses that type could generate an error message or provide automatic initialization. One problem with this solution is Modula-2's inability to control assignment of ADTs. Declaring ADT's as pointers to headers, and keeping a list of pointers to these headers would help, but I'm hoping someone will post a better solution (if anyone sees problems with this approach, please let me know too). Also, does anyone know of a method to provide automatic cleanup upon termination of an ADT's environment? Bob Hathaway afd@k.cc.purdue.edu