This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Kava for GCJ?


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/





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]