On 03/11/10 02:20, Gareth Charnock wrote:
On 03/11/10 00:54, bearophile wrote:
Is it correct for immutable struct fields to act like enum or static
const fields? (I don't think so, but I am wrong often):

struct Foo {
immutable int x = 1;
}
static assert(Foo.sizeof == 4);
void main() {}


More info in the D.learn thread:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=22540


Thank you,
bearophile

If it helps, the analogy I always use when explaining immutable is the
stone tablet. A running program can chip out a message on a stone tablet
(write to immutable memory) but once it's written once it's never going
to change again. When your done with a stone tablet all you can do is
throw it in the garbage but you can go and chip a new message on a new
stone tablet.

Don't worry, it took me a while before I realized that an immutable
didn't have to be known at compile time as well.

Ah, okay, I reread that. You meant is it correct for immutable to act like enum at any time, but I read all the time for some reason. Sorry.

Reply via email to