Do we really need const?
Regan Heath
regan at netmail.co.nz
Mon Sep 17 04:13:05 PDT 2007
Bill Baxter wrote:
> Matti Niemenmaa wrote:
>> Bill Baxter wrote:
>>> There's of course Java. Lots of enterprise software is written in Java,
>>> and yet Java does not have const.
>>
>> Java has a limited form of const in final, which allows for both
>> compile-time
>> constants and variables which can only be assigned to once.
>>
>> See the "variables" and "fields" sections here:
>> http://renaud.waldura.com/doc/java/final-keyword.shtml
>
> Yes, a lot of languages seem to have that form of const, which is more
> or less like const is in D1.x. That doesn't seem to be the problematic
> kind.
Java also has invariant strings which is another form of const, one that
makes multithreading easier.
It seems that there are at least 4 forms of const:
1. invariant data
2. invariant variables
3. logical const
4. transitive const
Forms #1 and #2 should combine well with 'pure' I imagine.
Regan
More information about the Digitalmars-d
mailing list