[EMAIL PROTECTED] wrote:

> On Wed, 13 Oct 1999, Robert Simmons wrote:
>
> > Since everything in java is passed by reference this becomes even more of an issue.
> > Therefore can I do the following to achieve the desired safety ?
>
> Well, everything is not passed by reference in Java.  I believe primitives
> and immutable types are passed by value.  Someone know the exact rules
> behind this? I always have to write a little test program to remember.
> Okay, I'll stop being pedantic.
>
> I think if you do
>
> public void myFunction(final SomeClass var) {
>         .. whatever ..
> }
>
> Will do what you desire.  Not positive though so some of the other wiser
> folks on the list might wish to confirm this.

Well  that wont compile.

In reality const is just one form of programing by contract which java does not support
directly
to date.

Since reference arguments are passed as a reference copy in java you cant change a
reference.

example

public void foo(  Object obj ) {
        obj =foobar;
}

Has no effect on the external pointer obj;
Pointers in java are passed also by copy .


To simulate a pointer in java you need

public void foo(  Object[] obj ) {
        obj [0]=foobar;
}

Thus a pointer is really a index into a array which is gasp the same thing it is in C.

The only thing you don't know in java is you absolute address from the true  offset in
memory.
JNI allows pinning if Java allowed you to pin the address of and array and allow byte[]
int[] etc to point to the same memory regions. And allow you to subclass say int[]
99.9999999% of the reasons to use C are gone.

The only reason you can't cast a int[] to   byte[]  is because java is big  endian and
intel is little  :  (

Why you can't subclass int[] or byte[]   I don't know.


Mike


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to