How Not to Write FORTRAN in Any Language
gManZboy writes "In an article that's sure to p/o Fortran programmers, Donn Seeley has assembled a rant that posits there are characteristics of good coding that transcend all programming languages, except Fortran. Seriously though, his point is that early FORTRAN made coding ugly. Thus the joke 'Don't write FORTRAN' was applied to anyone with ugly code. Though Fortran has in recent years overcome its early challenges, the point -- 'Don't write FORTRAN' (i.e. ugly stuff) -- still applies."
...is another man's wife.
Beauty is in the eye of the beholder. Perl certainly proves that.
I think naming conventions and style conventions are more about compulsiveness and xenophobia than they are about comprehensiveness or maintainability.
It's not that you can't understand This_Is_A_Big_Name when you're used to ThisIsABigName, it just that it disturbs and annoys you.
In C, multidimensional arrays are a fiction, because a[i][j] is given exactly the semantics of *(*(a + i) + j), instead of *(a + i * second_dim + j).
.file "test.c" .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "%d\n" .text .p2align 4,,15 .globl t1 .type t1, @function .size t1, .-t1 .p2align 4,,15 .globl main .type main, @function .size main, .-main .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.3.5 (Debian 1:3.3.5-6)"
This is a false statement. You need to learn C before you criticize it. The semantics of a[i][j] depend on the type they are applied to.
IF the type is int **a; then this a pointer to pointer(s) to int(s).
If I index it with a[i], The type of this expr is pointer to int, because of the initial pointer derefence, or *(a + i). If I index a[i][j], then this is another pointer dereference (because a[i] IS a pointer), so this *(*(a + i) + j), as you say.
However if the type were:
int a[M][N]; This is totally different, and this IS a true multidimensional array.
Technically, the type of the expression int a[i] is a CONST pointer (unlike last time where it was not necessarily const), because of the C rule that an unindexed array expression (the row in this case) evaluates as a constant pointer. It is constant because it is computed by (a + i * N). The second dimension is required to form the offset.
Computing the expression a[i][j] now involves no pointer dereference for lookup, because the a[M][N] array holds values of int ONLY, there are no pointers stored, so there is no way that a pointer could be dereferenced. In order to find the i'th row, it is necessary to know the j'th dimension to form the offset to the "next row array" which are all contiguous.
This is why in C, this is valid:
int foo(int a[][N]);
but this is not:
int foo(int a[][]);
C has to know the last dimensions in order to compute the offset into the array.
This is equivalent to: *(a + i * N + j).
Your knowledge of C is incomplete.
Even though you are obviously an idiot that doesn't let his lack of knowledge get in the way of proudly demonstrating it, I will paste something that might be helpful:
#include
int t1(int a[][3858], int i, int j)
{
printf("%d\n", a[i][j]);
}
int main()
{
int i=2384, j=327;
int a[85723][3858];
t1(a, i, j);
return 0;
}
and:
t1:
pushl %ebp
movl %esp, %ebp
movl 12(%ebp), %eax
movl 16(%ebp), %edx
imull $3858, %eax, %eax ------ FUCKWIT
addl %edx, %eax
movl 8(%ebp), %edx
movl (%edx,%eax,4), %eax
movl $.LC0, 8(%ebp)
movl %eax, 12(%ebp)
popl %ebp
jmp printf
main:
pushl %ebp
movl $327, %eax
movl %esp, %ebp
subl $1322877368, %esp
movl $2384, %ecx
andl $-16, %esp
movl %eax, 8(%esp)
leal -1322877352(%ebp), %eax
movl %ecx, 4(%esp)
movl %eax, (%esp)
call t1
movl %ebp, %esp
xorl %eax, %eax
popl %ebp
ret
Go fuck yourself you skilless, worthless cocksucker.