Kava for GCJ?
Mohan Embar
gnustuff@thisiscool.com
Sat Jul 5 12:46:00 GMT 2003
Hi Kees,
>> Because treating a class as 'by value' alters the semantics of
>>>> Thing a = new Thing();
>> Thing b = a;
>>Only if there is some way to detect the difference. That's one of the
>reasons there are often restrictions on `by value' classes. For example,
>in James Gosling's proposal there are the following restrictions:
>>- All fields must be 'final'
>- class variables may not be compared to each other
>>Under these restrictions your example code has the same visible effect
>for reference and value classes.
Maybe this is a dumb question, but could you explain to me how
Adam's code has the same visible effect for reference and value
classes with your additional restrictions? Taking Adam's example
one step further:
a.setState(Thing.HAPPY);
b.setState(Thing.SAD);
If the declaration:
Thing b = a;
has value semantics, then a is now happy and b is now
sad. However, in Java, where b gets a reference to a, b
and a are now both sad.
Am I misunderstanding something?
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/
More information about the Java
mailing list