Re: [CodeGallery] MFC MD5 Calculator
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Sun, 28 Sep 2008 12:01:11 -0400
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 [MVP]
"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
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- [CodeGallery] MFC MD5 Calculator
- From: Giovanni Dicanio
- Re: [CodeGallery] MFC MD5 Calculator
- From: Xavier
- Re: [CodeGallery] MFC MD5 Calculator
- From: Giovanni Dicanio
- Re: [CodeGallery] MFC MD5 Calculator
- From: Joseph M . Newcomer
- Re: [CodeGallery] MFC MD5 Calculator
- From: Giovanni Dicanio
- [CodeGallery] MFC MD5 Calculator
- Prev by Date: Re: Porting from VC6 to VS2005
- Next by Date: Re: Porting from VC6 to VS2005
- Previous by thread: Re: [CodeGallery] MFC MD5 Calculator
- Next by thread: Re: [CodeGallery] MFC MD5 Calculator
- Index(es):
Relevant Pages
|