Related articles |
---|
Adding const to java lashari@hotmail.com (Ghulam Lashari) (2002-10-24) |
Re: Adding const to java onderkarpat@yahoo.com (Onder Karpat) (2002-11-06) |
Re: Adding const to java joachim_d@gmx.de (Joachim Durchholz) (2002-11-06) |
Re: Adding const to java titzer@expert.ics.purdue.edu (Ben L. Titzer) (2002-11-06) |
Re: Adding const to java hagge@isde.uni-hannover.de (Nils Hagge) (2002-11-06) |
Re: Adding const to java C.vanReeuwijk@twi.tudelft.nl (Kees van Reeuwijk) (2002-11-06) |
From: | "Ben L. Titzer" <titzer@expert.ics.purdue.edu> |
Newsgroups: | comp.compilers |
Date: | 6 Nov 2002 11:50:31 -0500 |
Organization: | Purdue University |
References: | 02-10-101 |
Keywords: | Java |
Posted-Date: | 06 Nov 2002 11:50:31 EST |
On 24 Oct 2002, Ghulam Lashari wrote:
> I have implemented "const" modifier in Java Programming Language. The
> semantics of const are similar to that of C++. I am trying to experiment if
> there is any usefulness of this modifier for example in gc etc. I am looking
> for some opinions/suggestions here about what domains of the usefulness of
> this modifier can/should be explored (for example in Virtual Machine
> runtime).
How do the semantics of this modifier differ from final? In that you
can't modify the fields of the particular object?
IMO, I think const is the biggest pain in the ass in C++. Objects are
either going to have public fields or not. Doing this on a per
reference basis is a mess. Besides, it's all subvertible anyway.
As for the usefulness for the runtime, it's isn't all that useful.
Specifying that a section of code will only read a field and not write
it isn't particularly useful in itself. Caching wouldn't be correct
because the field could still be changed concurrently or by methods up
the call stack. Final is more useful for compilers because the field
can be cached without worry about concurrent modification.
-B
Return to the
comp.compilers page.
Search the
comp.compilers archives again.