From mboxrd@z Thu Jan 1 00:00:00 1970 Mime-Version: 1.0 (Apple Message framework v619.2) In-Reply-To: References: Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <5ef017b602f99114e817ac37589aef3d@coraid.com> Content-Transfer-Encoding: 7bit From: Brantley Coile Subject: Re: [9fans] OT: programming style under Plan9?? Date: Fri, 1 Apr 2005 22:34:31 -0500 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Topicbox-Message-UUID: 30abb086-ead0-11e9-9d60-3106f5b1d025 Speaking as a semi old fart, some of the early structure of programs into separate files was just to keep the file small enough to compile quickly. Dennis' pdp11 compiler was a number of files that all essentially got cat'ed together. Back when a MIP was a real MIP and you had only one, having the source in small files really sped up compilation. You could get a lot more work done in a given amount of time. The first thing I noticed when I first saw the Plan 9 code in 1990 was how header definitions were combined into the same file. This turned out to be a great win. Of course, a more constructive answer would be to get a copy of ``The Practice of Programming'' by Kerninghan and Pike. I would make the remark that C doesn't have modules. After compiling the code type information is lost and you can link to anything that will resolve a name. For example I can treat the name qsort(3) as an array of integers. The loader will resolve the name qsort and the code in main will just do what I told it to. This in in contrast to Wirth's Oberon that does type checking at compile, link and runtimes. #include extern int qsort[10]; void main(void) { int i; for (i = 0; i < 10; i++) printf("%08x\n", qsort[i]); exit(0); } Brantley On Apr 1, 2005, at 8:34 PM, I RATTAN wrote: > I have observed that that the Plan9 C-code generally > consists fo ALL modules of a program are in the same file. > Is it deliberate or a matter of style? It does make life > easier in terms of include files but seems a bit little off > key in context that C supports separate compilation of modules > and hence, each module could be in a file of its own! I was accused > of being University type in comp.lang.python for asking how > keep each modules in a separate file and make the program > work correctly. > > Thanks in advance. > -ishwar >