www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - immutable storage class?

reply Sergey Kovrov <kovrov+digitalmars gmail.com> writes:
I cannot find any information about immutable keyword. I presume it is a
storage class and should be described in "Declarations" manual page, but it is
not. On the other hand it is mentioned in changelog and some manual pages. Is
it an alias for invariant or const, or something completely different?

-- serg.
Mar 06 2009
next sibling parent bearophile <bearophileHUGS lycos.com> writes:
Sergey Kovrov:

Is it an alias for invariant or const, or something completely different?<
I think it's the new (correct) name for invariant. Bye, bearophile
Mar 06 2009
prev sibling next sibling parent reply Sergey Kovrov <kovrov+digitalmars gmail.com> writes:
From playing with compiler looks like immutable and invariant are practically
interchangeable. And typeof reports that invariant is really immutable. I
personally like immutable keyword better, but wonder if it is just a change of
name or something more?

-- serg.
Mar 06 2009
parent Robert Fraser <fraserofthenight gmail.com> writes:
Sergey Kovrov wrote:
 From playing with compiler looks like immutable and invariant are practically
interchangeable. And typeof reports that invariant is really immutable. I
personally like immutable keyword better, but wonder if it is just a change of
name or something more?
 
 -- serg.
From the newsgroup discussions, it's just a change of name, with the exception that only invariant can be used for class invariants: class Foo { invariant() { } }
Mar 12 2009
prev sibling next sibling parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Sergey Kovrov wrote:
 I cannot find any information about immutable keyword.
<snip> http://d.puremagic.com/issues/show_bug.cgi?id=2572 Stewart.
Mar 06 2009
prev sibling parent Jesse Phillips <jessekphillips gmail.com> writes:
On Fri, 06 Mar 2009 08:58:04 -0500, Sergey Kovrov wrote:

 I cannot find any information about immutable keyword. I presume it is a
 storage class and should be described in "Declarations" manual page, but
 it is not. On the other hand it is mentioned in changelog and some
 manual pages. Is it an alias for invariant or const, or something
 completely different?
 
 -- serg.
I'm not sure what is the real reason for it's existence, but it seems many people prefer the term immutable over invariant. So I guessed that Walter is planning on changing the name to immutable. He might keep both in there, but I really don't think that is a good idea.
Mar 06 2009