Re: Adding const to java

"Ben L. Titzer" <>
6 Nov 2002 11:50:31 -0500

          From comp.compilers

Related articles
Adding const to java (Ghulam Lashari) (2002-10-24)
Re: Adding const to java (Onder Karpat) (2002-11-06)
Re: Adding const to java (Joachim Durchholz) (2002-11-06)
Re: Adding const to java (Ben L. Titzer) (2002-11-06)
Re: Adding const to java (Nils Hagge) (2002-11-06)
Re: Adding const to java (Kees van Reeuwijk) (2002-11-06)
| List of all articles for this month |

From: "Ben L. Titzer" <>
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.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.