I meant, they were not clever enough to optimize array accesses properly - they simply converted them to pointers by using this well-known property |
I assume you mean stack arrays.
1. If y in x[y] is a variable not even a modern compiler can optimize it. It has to fallback to pointer arithmetic.
2. No, stack arrays can't completely replace pointer arithmetic, anyway.
Undefined behaviour because of 3 reasons: |
My bad. I was going to write something else and changed my mind as I was writing it. This is what I meant:
1 2 3 4 5
|
void f(int *p){
int a;
p=&a;
*p=0;
}
| |
Show the evidence it cannot be. |
I don't need to. You're the one trying to prove statistically that in most of the world Java programmers make as much money as C++ programmers while at the same time there being more openings. Show me a statistic than can be reasonably applied to most of the world or shut up, but don't show me one of a small portion of it, perform some preposterous extrapolation on it, and then ask me to accept it as valid. Alternatively, provide a statistic that disproves my anecdotal evidence that where I live C++ programmers are more valuable.
Anyway, it doesn't claim anywhere Java is pass-by-reference. |
What, you need concrete examples to be convinced? There's this thing called abstraction; you might want to try it out.
I'm sure you'll find the exact same definition in any programming book. This isn't some super-advanced concept, man. I studied this definition in my second year of Laboratory (probably one of the few highlight of an otherwise mediocre year).
And from the definition written there - it certainly isn't. Java is pass-by-value, dude, and it always has been. |
I can't believe I need to explain this.
Let's take a look at this:
1 2 3
|
void f(int *p){
*p=0;
}
| |
Yes, p is indeed being passed by value,
but the data p points to, which is what's of real interest to this function is being passed by reference (pass by reference is a generic term that refers to passing an argument to a function without making a copy of that argument, regardless of the means used to pass that argument [pointers, C++ references, COW semantics, whatever]). The fact that the pointer is being copied isn't relevant. The call is still by reference.