This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Kava for GCJ?
- From: Mohan Embar <gnustuff at thisiscool dot com>
- To: Adam Megacz <gcj at lists dot megacz dot com>, "C. van Reeuwijk" <C dot vanReeuwijk at its dot tudelft dot nl>
- Cc: java at gcc dot gnu dot org
- Date: Sat, 05 Jul 2003 07:46:21 -0500
- Subject: Re: Kava for GCJ?
- Reply-to: gnustuff at thisiscool dot com
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/