On Tue, Jun 21, 2016 at 01:48:27PM +, jmh530 via Digitalmars-d-learn wrote:
[...]
> Thanks to you and the others for the detailed clarifications. I think
> part of the difficulty is that there are basically three things being
> discussed that are all very similar: an alias to data, a pointer
On Tuesday, 21 June 2016 at 15:21:01 UTC, Ali Çehreli wrote:
[snip]
Thanks.
On 06/21/2016 06:48 AM, jmh530 wrote:
> So an immutable pointer guarantees that whatever it is pointing to will
> never change,
Yes but saying "_requires_ that data never changes" is more correct.
When it comes to a pointer (i.e. the user of data), "guarantee" is
related to const.
> but a
On Tuesday, 21 June 2016 at 02:54:06 UTC, ketmar wrote:
Thanks to you and the others for the detailed clarifications. I
think part of the difficulty is that there are basically three
things being discussed that are all very similar: an alias to
data, a pointer to data, and a view of data.
behavior is identical. And really, if you never need to take
the address of the variable, then a manifest constant using
enum would be more appropriate.
Actually, I should say it *may* be more appropriate. Definitely
only when the initializer is known at compile time. There are
cases when
On Tue, Jun 21, 2016 at 02:24:03AM +, jmh530 via Digitalmars-d-learn wrote:
> I feel like I have a reasonable understanding of when to use const as
> a parameter in a function or for const member functions. However, I
> don't really understand why/when it should be used as a type modifier.
>
On Tuesday, 21 June 2016 at 02:24:03 UTC, jmh530 wrote:
So the line from the spec is
"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."
I tried making an alias of a const variable and modifying
I feel like I have a reasonable understanding of when to use
const as a parameter in a function or for const member functions.
However, I don't really understand why/when it should be used as
a type modifier.
For instance, the Programming in D book basically just says