Re: how to design a replacement for C++
On Jul 29, 5:28 am, ralph <nt_consultin...@yahoo.net> wrote:
On Wed, 28 Jul 2010 18:48:08 -0700 (PDT), Joshua Maurice
<joshuamaur...@gmail.com> wrote:
I feel the exact same way about the word "pointer". Oh how much I
loathe talking about Java "references". They should rightfully be
called pointers. I've had several fun conversations about how all Java
functions pass by value, and people will say "nu uh!" because it's "a
reference". The object is not copied, but the reference is copied.
Modifying a parameter reference will not modify the callers reference,
but modifying the pointed-to object in the function will modify the
caller's object. This sounds a whole lot like pointers to me.
Java doesn't have 'pointers'.
But it does have a NullPointerException. The authors of Java
obviously felt that it had pointers.
Period. Sorry that makes you ill, but it is a simple fact.
Java was deliberately designed to not have them.
Java was deliberately specified not to use the word pointer.
A reference in Java, however, is more like a pointer in C++ than
it is like a reference. And it corresponds to the usual use of
the word pointer in computer science.
[...]
The other part is that a language that truly supports pointers
must also support pointer arithmetic.
Why? Pascal and company had "pointers", but no pointer
arithmetic. PL/1 had pointers (long before there was C), but
I don't think it had pointer arithmetic. Ada has pointers
(declared using the keyword "access"), but no pointer
arithmetic. In fact, C and C++ are about the only languages
I know which support pointer arithmetic.
--
James Kanze