Path: utzoo!attcan!uunet!ginosko!brutus.cs.uiuc.edu!apple!oliveb!Ozona!chase From: chase@Ozona.orc.olivetti.com (David Chase) Newsgroups: comp.lang.misc Subject: Re: Header files Message-ID: <48551@oliveb.olivetti.com> Date: 27 Sep 89 20:29:07 GMT References: <24955@louie.udel.EDU> Sender: news@oliveb.olivetti.com Reply-To: chase@Ozona.UUCP (David Chase) Organization: Olivetti Research California, Menlo Park, CA Lines: 35 In article <24955@louie.udel.EDU> new@udel.EDU (Darren New) writes: >One thing I have always liked about the C language was the separation >between the "header" files (.h) and the "code" files (.c). In other >languages, such as Modula-II and (I think) Ada, it is not possible to >define multiple "implementation" modules for a single "definition" >module. >Does anyone know of any relatively popular languages that allow this >sort of separation other than C and C++? If not, why not? Discussion? Modula-3 allows this separation (popular?). It's a bit of a pain, actually, since there's (for the moment) data structures which need initialization at run-time. Given, say "MODULE A EXPORTS B", it isn't really clear whether or not the code generated for this module should initialize the data structures for B, since there might also be some MODULE C exporting B. These run-time structures are required because Modula-3(revised unpublished report) has Neat New Features like "opaque supertypes" (that's a supertype, but you don't know how many methods it has or what or how large the fields are) and constants of types exported by "required interfaces" (meaning that the constant is initialized at *run time* by the implementation of the required interface) and default field values for allocated records and objects (even for the fields in the opaque supertype). What we do now is generate the init code in all possible exporters; typically the number of exporters is small, so this doesn't kill us, but it isn't wonderful. The pre-linker is getting smarter too, so in several cases the redundant code is generated, but not executed. Still, it is a hassle. Several things would be easier if (a) we weren't generating C as an intermediate language and (b) the Unix linker (SunOS 3.5, and apparently also 4.0) wasn't quite as dumb as a rock. David