Author |
Message |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Wed Mar 30, 2005 7:43 pm Post maybe stupid Post subject: |
 |
|
|
|
Cerium wrote: | For the record...
Everything in java is passed by value, nothing is passed by reference.
Objects are essentially pointers. When you pass an object to a function, youre passing the reference to that object by value. |
In that case, even in C++, there is no such thing as by reference. References are essentially pointers. When you pass a reference to a function, you're passing the pointer to that object by value.
You're wrong  _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Wed Mar 30, 2005 8:20 pm Post maybe stupid Post subject: |
 |
|
|
|
I was under the impression that basically every object in code is actually a pointer to a real instance. _________________
 |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Wed Mar 30, 2005 8:41 pm Post maybe stupid Post subject: |
 |
|
|
|
Well, you can't very well typedef in ASM. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
 |
Cerium Server Help Squatter

Age:43 Gender: Joined: Mar 05 2005 Posts: 807 Location: I will stab you. Offline
|
Posted: Wed Mar 30, 2005 11:39 pm Post maybe stupid Post subject: |
 |
|
|
|
Dr Brain wrote: | In that case, even in C++, there is no such thing as by reference. References are essentially pointers. When you pass a reference to a function, you're passing the pointer to that object by value.
|
The difference is in C/Cpp you have a choice, Java you do not. (Aside from the copy() method, assuming its been overloaded by the object in question.)
Although, in Java 5, the lines are a bit more blurred as primitives are auto boxed and unboxed now, making a 'by ref' style primitive easier to setup.
Dr Brain wrote: | You're wrong  |
Umm... I was indirectly quoting two sources: One of my CS professors and a Java tutorial written by Sun. Interpret it how you will, but thats how it works.
Bak wrote: | structs are just classes with everthing public, which is quite possible in Java |
One word: Bitfields.
Can be done in Java, just requires more work from the developer. |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Mar 31, 2005 12:14 am Post maybe stupid Post subject: |
 |
|
|
|
You said everything was pass by value. That's wrong. Pass by value has a meaning, a meaning which passing by reference does not fulfill.
You're correct that in Java, everything is references, but you're wrong about everything else.
I'm afraid I have very little respect for the views of CS professors. My current CS class has the professor deferring to me on all technical Java questions. |
|
Back to top |
|
 |
Cerium Server Help Squatter

Age:43 Gender: Joined: Mar 05 2005 Posts: 807 Location: I will stab you. Offline
|
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Thu Mar 31, 2005 11:49 am Post maybe stupid Post subject: |
 |
|
|
|
java passes by value -> copy of the reference. (see below by dr brain)
public void blah(int []a) {
a = new int[3];
}
meaning the address of 'a' is locked, it wont be changed. etc. etc. _________________ Performance is often the art of cheating carefully. - James Gosling
Last edited by CypherJF on Thu Mar 31, 2005 12:39 pm, edited 1 time in total |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Mar 31, 2005 12:08 pm Post maybe stupid Post subject: |
 |
|
|
|
Cerium, do you have any fucking clue how passing by reference works in C++? How about passing by reference in Java? It's the same (allowing for the fact that C++ objects don't alway get allocated on the heap). Passing by reference is different than passing by value.
Passing by value means something. Passing by reference means passing a pointer to an object to a function. Passing by value MEANS passing a copy of that object to the functions. Notice that they are not the same thing. The keyword is copy. Java passes copies of the underlying pointers, yes, but no copy of the object is made.
Please, do yourself a favor, learn the difference. |
|
Back to top |
|
 |
Guest
Offline
|
Posted: Thu Mar 31, 2005 12:37 pm Post maybe stupid Post subject: |
 |
|
|
|
CypherJF wrote: | java passes by value -> copy reference. (see below by dr brain)
public void blah(int []a) {
a = new int[3];
}
meaning the address of 'a' is locked, it wont be changed. etc. etc. |
|
|
Back to top |
|
 |
Cerium Server Help Squatter

Age:43 Gender: Joined: Mar 05 2005 Posts: 807 Location: I will stab you. Offline
|
Posted: Thu Mar 31, 2005 12:41 pm Post maybe stupid Post subject: |
 |
|
|
|
Dr Brain wrote: | <insert internet anger here> |
Look guy, dont be mad at me. Im well aware of the difference between the two, youre the one who seems confused.
Continue to argue semantics all you want. Java passes by value always. If you want to use the term 'by ref' whenever you pass an object reference to a function (notice how redundant that sounds?) feel free. But Im not going to continue debating this. Think Im a dumbass for all I care. Youre only hurting yourself. |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Thu Mar 31, 2005 2:33 pm Post maybe stupid Post subject: |
 |
|
|
|
yawn that guest was me, i accidentally quoted instead of actually reading... i thought i was logged in and was clicking edit haha |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Thu Mar 31, 2005 5:54 pm Post maybe stupid Post subject: |
 |
|
|
|
Yeah it definately passes by reference. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Thu Mar 31, 2005 11:29 pm Post maybe stupid Post subject: |
 |
|
|
|
Umm, right. Java passes the pointers by value, the objects by reference. It's just different ways of looking at it. No matter what you're passing by whatever means, you're always passing some value. |
|
Back to top |
|
 |
SamHughes Server Help Squatter

Joined: Jun 30 2004 Posts: 251 Location: Greenwich Offline
|
Posted: Fri Apr 01, 2005 12:43 pm Post maybe stupid Post subject: |
 |
|
|
|
Arguments get depressing when all that's left to discuss is terminology. Stop worrying about Java and C++; they are both ugly languages anyway. Go learn some Haskell and reconnect with your inner child. |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Fri Apr 01, 2005 2:46 pm Post maybe stupid Post subject: |
 |
|
|
|
ADA ALL THE WAY! |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Fri Apr 01, 2005 6:53 pm Post maybe stupid Post subject: |
 |
|
|
|
BrainF*ck is interesting |
|
Back to top |
|
 |
|