Re: [CodeGallery] MFC MD5 Calculator



And did you ever wonder why functions such as time() take an unsigned long * (excuse me,
time_t *) instead of returning the time directly? That's because the original K&R C could
only return int-sized objects (specifically, 16-bits on the PDP-11) and therefore there
was no mechanism for returning OTHER than int. A function was declared as

extern func();

because int as a return type was implied, and the number of arguments could be anything
(as already pointed out). But the declaration extern func() was completely redundant, and
unnecessary, because if you wrote
funct(1, 2, 3);

it knew you were calling a function. Besides, the linker would catch the fact that you
had called funct because it would report it as an undefined symbol. Unless, of course,
you had another function called funct, that took different arguments, in which case it
would call that function, erroneously, but hey, no program could be longer than a couple
thousand lines (remember, we were talking TINY machines, a BIG machine had 32K, a GIGANTIC
machine had 64K) so you could find all the bugs by quick visual inspection of the source.

Don't get me started on the separate-I-and-D spaces issue of the PDP-11/40...think "MS-DOS
with segment registers" and you have the basic idea...(Intel did not invent all the bad
ideas in architecture, believe me. The IBM/360 didn't even have virtual memory, and only
had 4 protection bits, because who could imagine running more than 15 programs on a
mainframe? Protection code 00 was the kernel).

We found when we produced a C compiler that it would not have market acceptance because
you couldn't compile the Unix kernel with it. As it turned out, it had optimized register
allocation, so the register assignments changed, and all the sed scripts that were
necessary to run on the generated assembly code from the C compiler to make the code
actually work in the kernel, broke, because they were looking for specific register
assignments...

It really was a Different World. The great thing about the Good Old Days is that they are
in the past, and we don't have to live with the limitations and crude tools we used then.
joe

On Sun, 28 Sep 2008 10:50:36 +0200, "Giovanni Dicanio"
<giovanniDOTdicanio@xxxxxxxxxxxxxxxxx> wrote:


"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> ha scritto nel messaggio
news:bcvtd4pc35fb44eeftem4u8ivsenhp6qcl@xxxxxxxxxx

[...]
I programmed in this tenth-rate piece of crap for about five years, hating
every minute of
it. It ranks among the worst languages ever designed. It wasn't until
the idea of an
ANSI standard (and later an ISO standard) began to emerge that the
language design
community got enough power to replace this piece of crap with real
function prototypes
that had compile-time type-checking.

Thanks for the historical perspective, Joe.

Now it is very clear to me the origin of Hungarian Notation.

I'm glad that I started learning C when there was already compile-time
prototype checkings, without "unsane" things like the "#define void int" :)


In those days, struct fields were global names, so if you had

struct Point2 { int x; int y; };
you could not have another
struct Point3 { int z; int y; int x;}

because x was a global value which was an offset of 0 into a structure.
So you could
write

int A;
A.y = 2;

...Coding "horror" !


Giovanni
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • [PATCH,RFC 2.6.14 08/15] KGDB: x86_64-specific changes
    ... +int kgdb_remove_hw_break ... +static struct pt_regs *in_interrupt_stack ... +/* Register KGDB with the die_chain so that we hook into all of the right ...
    (Linux-Kernel)
  • Re: Passing an already declarted array of structures!
    ... void LCD_PAINTSCREEN ... in above code by "int", ... If you guys see nothing wrong with the code, then I suppose its a compiler ... struct S { ...
    (microsoft.public.vc.language)
  • [MC++] Internal Compiler Error with /Ox
    ... ("NullReferenceException with value struct") ... __value struct Contours { ... int num_contours; ... Microsoft C/C++ Optimizing Compiler Version 13.10.3077 for .NET Framework ...
    (microsoft.public.dotnet.languages.vc)
  • Re: void * vs char *
    ... cast p to a (struct s*) to avoid a compile-time error. ... struct s {int a;}; ... function call consists solely of an identifier, and if no declaration ... And see what your compiler has to say. ...
    (comp.lang.c)
  • Re: Delay Routine: Fully-portable C89 if possible
    ... non-standard compiler with 8-bit shorts than a standard compiler with ... Embedded compilers sometimes support different sized types as extensions, beyond what is available through char, short int, int, long int and long long int. ... You mean padding the struct with extra elements, ... it avoids multiplies on lookups - multiplies can be costly on ...
    (comp.arch.embedded)