void foo(immutable int* x, int* y) {
bar(*x); // bar(3)
*y = 4; // undefined behavior
bar(*x); // bar(??)
}
...
int i = 3;
foo(cast(immutable)i, i);
--
In the 2.065 version, I can compile. But that is not in the
documentation.
There, how to distinguish between const and immutable? thank
you~:)
/**
Const types are like immutable types, except that const forms a
read-only view of data. Other aliases to that same data may
change it at any time.
Any data referenced by the const declaration cannot be changed
from
On Thursday, 3 July 2014 at 21:06:12 UTC, Jet wrote:
There, how to distinguish between const and immutable? thank
you~:)
/**
Const types are like immutable types, except that const forms
a read-only view of data. Other aliases to that same data may
change it at any time.
Any data
On Thursday, 3 July 2014 at 20:43:33 UTC, Jet wrote:
void foo(immutable int* x, int* y) {
bar(*x); // bar(3)
*y = 4; // undefined behavior
bar(*x); // bar(??)
}
...
int i = 3;
foo(cast(immutable)i, i);
--
In the 2.065 version, I can compile. But that is not in
On Thu, Jul 03, 2014 at 09:06:11PM +, Jet via Digitalmars-d-learn wrote:
There, how to distinguish between const and immutable? thank you~:)
/**
Const types are like immutable types, except that const forms a
read-only view of data. Other aliases to that same data may change it
at any
Thank you all. These answers are very detailed. I think I learned
a lot.
Awesome!!!
Thank you so much!
On 07/03/2014 01:43 PM, Jet wrote:
void foo(immutable int* x, int* y) {
bar(*x); // bar(3)
*y = 4; // undefined behavior
bar(*x); // bar(??)
}
...
int i = 3;
foo(cast(immutable)i, i);
--
In the 2.065 version, I can compile. But that is not in the