Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site h-sc1.UUCP Path: utzoo!linus!decvax!genrad!panda!talcott!harvard!h-sc1!thau From: thau@h-sc1.UUCP (robert thau) Newsgroups: net.lang.c Subject: Re: Proposal to add modules to C with a simple extension. Message-ID: <323@h-sc1.UUCP> Date: Sat, 4-May-85 12:30:17 EDT Article-I.D.: h-sc1.323 Posted: Sat May 4 12:30:17 1985 Date-Received: Tue, 7-May-85 20:24:53 EDT References: <224@sdcc13.UUCP> Organization: Harvard Univ. Science Center Lines: 53 > Overview: > I'm sure most of you (like me) find the method of information hiding > in C a bit excentric, but learn to live with it... > > Proposal: > Allow blocks (modules) at the outermost (global) level of scope. > The code inside of these blocks is treated as if it were in a separate file. The syntax proposed is: int really_global_var; /* To set up context for the example ... */ { /* Begin module */ int module_var_1; /* Variables invisible outside the module */ char module_buffer[MAGICNUMBER]; ... functions using the variables ... } This leaves int externfunc(); { /* module here */ } looking too much like int externfunc() { /* Because of the missing ;, this becomes a function defn. */ } A new reserved word seems called for. > I think global variables within a module should be implied to be of "static" > type within the module, and functions implied to be of "extern" type within > the file that includes the module. This explicitly shows which variables are > shared within the module. [A minor point, I'll leave to language sematicians] > Modules, of course, could be nested with the expected results. I admit that this would make most module code a bit neater. The problem is that declarations in C are already a mess. Function arguments declared array are automatically coerced to pointer; variables declared in a compound statement are of storage class auto by default, except if they're functions, in which case the default is external, and so on. The last thing the language needs is yet another special case; my own humble opinion is that it would be better to keep the default 'extern' of files, so as not to drive everybody nuts. Aside from these gripes, I think the idea is a good one. Robert Thau rst@tardis.ARPA h-sc1%thau@harvard.ARPA