Re: problems with Java
- From: Tom Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Sat, 31 Mar 2007 01:53:50 +0100
Lew wrote:
ender <astrothayne@xxxxxxxxx> wrote:The second thing is that you should have more control over how objects
are passed. Although pass by reference is preferable in most cases
there are many instances when pass by value is required, having to
constantly use clone() is not a very efficient, or safe way.
Huh? I never use clone(), and Java doesn't pass by reference, it passes by value.
Technically it passes references by value, but the effect is to pass a reference. I think it's splitting hairs, rather than showing anyone's misunderstanding of the language.
You probably don't use clone, but you do use constructors that copy.
I'm not sure what you are claiming to accomplish, but I am sure there are Java-idiomatic ways to whatever it is.
I believe what the original poster is referring to is the need to copy your arguments and return values. There's a bit of a problem, in that the type doesn't give you enough information. I want to return a Set<K>, should I make a copy? Well, no, not if the method is keySet(). Suppose I did make a copy, what implementation should I use? Do I always want to make a copy, even from private methods? It's a problem, but I think if you wanted to solve it in the language, there are better ways to go about it.
Tom Hawtin
.
- References:
- problems with Java
- From: ender
- Re: problems with Java
- From: Mark Rafn
- Re: problems with Java
- From: Matt Humphrey
- Re: problems with Java
- From: Lew
- problems with Java
- Prev by Date: Re: problems with Java
- Next by Date: Re: problems with Java
- Previous by thread: Re: problems with Java
- Next by thread: Re: problems with Java
- Index(es):
Relevant Pages
|