4 ms·
I worked with a lot of K&R C in the early 1990s, getting software to run on newer compilers and Solaris. I actually learned C++ before I learned C. It still loo
by alayne 12y ago
I worked with a lot of K&R C in the early 1990s, getting software to run on newer compilers and Solaris. I actually learned C++ before I learned C. It still looks strange to me. I believe the parameter declaration style comes from ALGOL (please correct me).
- david-given 12y agoI quite like K&R C --- it has an elegant minimalism to it that was lost in ANSI C: add(a, b, c) { return a+b+c; } But the ad-hoc parameter types only really worked if all your types were the same size, so it doesn't really get on with 64-bit machines. (I have just fixed some ancient code which was doing this: msg(s, a1, a2, a3, a4) char* s; { printf("info: "); printf(s, a1, a2, a3, a4); } ...later... { msg("an int is %d", anInt); msg("a string is %s", aString); } Yeah, no. I don't know classic Algol, but I've dabbled in Algol-68 (a most underrated language), and in that the parameter passing syntax is unrelated. The add function would have looked like: proc add = (int a, int b, int c): (a + b + c)
- ufo 12y agoIt does look similar to the ALGOL 60 syntax for procedures: https://en.wikipedia.org/wiki/Algol_60#ALGOL_60 https://en.wikipedia.org/wiki/Algol_60#ALGOL_60 procedure Absmax(a) Size:(n, m) Result:(y) Subscripts:(i, k); value n, m; array a; integer n, m, i, k; real y; comment The absolute greatest element of the matrix a, of size n by m, is transferred to y, and the subscripts of this element to i and k; begin integer p, q; y := 0; i := k := 1; for p := 1 step 1 until n do for q := 1 step 1 until m do if abs(a[p, q]) > y then begin y := abs(a[p, q]); i := p; k := q end end Absmax