Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Looks like a very early dialect. C assumes everything is an int unless specified otherwise. You can declare parameter types after the function name. So:

  init(s, t)
  char s[]; {
would be equivalent to:

  int init(char s[], int t) {
This still works with modern compilers.

I'd be interested if anyone has any more info about this:

  waste()		/* waste space */
  {
  	waste(waste(waste),waste(waste),waste(waste));
  	waste(waste(waste),waste(waste),waste(waste));
  	waste(waste(waste),waste(waste),waste(waste));
  	waste(waste(waste),waste(waste),waste(waste));
  	waste(waste(waste),waste(waste),waste(waste));
  	waste(waste(waste),waste(waste),waste(waste));
  	waste(waste(waste),waste(waste),waste(waste));
  	waste(waste(waste),waste(waste),waste(waste));
  }
Found in last1120c/c10.c


From the linked description (http://www.cs.bell-labs.com/who/dmr/primevalC.html):

A second, less noticeable, but astonishing peculiarity is the space allocation: temporary storage is allocated that deliberately overwrites the beginning of the program, smashing its initialization code to save space. The two compilers differ in the details in how they cope with this. In the earlier one, the start is found by naming a function; in the later, the start is simply taken to be 0. This indicates that the first compiler was written before we had a machine with memory mapping, so the origin of the program was not at location 0, whereas by the time of the second, we had a PDP-11 that did provide mapping. (See the Unix History paper). In one of the files (prestruct-c/c10.c) the kludgery is especially evident.


Doh, I completely glossed over the readme and went straight to the code. That makes sense -- Thanks!

Cool to think that that waste function can still compile with todays compilers. A quick disassembly it seems to take up 751 bytes compiled on x64 using clang on O0.


That was the standard way of declaring parameter types until ANSI C in 1989. C actually copied the current style back from C++.


ANSI C didn't drop old-style (non-prototype) function declarations and definitions -- nor did C99 or C11. They've been officially obsolescent since 1989, but they're still fully supported by any conforming compiler.


> Looks like a very early dialect. C assumes everything is an int unless specified otherwise.

It looks beautiful, almost like a scripting language. No monster type signatures like

    const std::foo_bar<boost::blah_ptr<const xyz::bar::Bar&, baz::Baz>>&


I think the modem carrier dropped on your last line. Can you resend?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: