Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why is C not consistent

Name: Anonymous 2012-05-10 1:43

Take the following two declarations "int arr[3]" and "int *ptr".

Both require different storage, but in usage both are identical. This behaviour  is known, and it is not the consistency I am talking about.

Take the following two declarations:

void funcarr(int a, int arr[3], int c)
{ printf("%d\n", &c-&a); }

void funcptr(int a, int *ptr, int c)
{ printf("%d\n", &c-&a); }

For funcarr, all three arguments are intended to be call by value. So I would expect the stack to contain
a,arr[0],arr[1],arr[2],c
but it does not. The stack contains
a,&arr[0],c

This is *NOT* consistent, and gives a false impression that the elements of arr[] will not change within the lifetime of the function.

Who failed, so I knows whose ass to kick.

Name: Anonymous 2012-05-14 0:44

>>38
You still don't fucking get it. The code fragment in >>33 is B, not C. The naked statement "a[5];" declares an array of five ints. "int" was not a keyword in B, because it was the only type; everything was an int.

Also, who the fuck mentioned C++? I'm not talking about C++ reference types. I'm talking about THE ACTUAL FUCKING MEANING OF THE WORD REFERENCE. If you pass the value of a pointer to an array, semantically you are passing the array by reference.

Yes the language passes the pointer by value, congratulations you fucking get that. Now think: WHY are we passing the value of a pointer? Oh, because we want to be able to REFER to the array contents in the function; we want a REFERENCE to the array, so we pass the POINTER BY VALUE.

Look up a dictionary some time you complete goddamn fucking moron.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List