Purity with references and pointers
Don
nospam at nospam.com
Mon Sep 20 04:07:06 PDT 2010
Simen kjaeraas wrote:
> Jonathan M Davis <jmdavisProg at gmx.com> wrote:
>
>> Except that since when is anything implictly convertable to immutable?
>> Implicitly converted to const, yes. That happens often enough, but
>> immutable?
>
> Anything that does not contain pointers or references to non-immutable
> data is implicitly convertible to immutable, if passed by value.
>
>
>> And you definitely don't have to use immutable references with pure
>> functions.
>
> That sounds like a bug. Unless you mean things like immutable(char)[],
> which is implicitly convertible to immutable, according to the above rules.
>
>
>> I have gotten some const-related errors when using pure on member
>> functions, so
>> I get the impression that using pure on a member function implicitly
>> makes it
>> const, but I'm not sure if that's enough.
>
> The 'this' pointer is also a parameter to a function, so also needs to
> be immutable.
But that's impossible, except for trivial, useless classes.
More information about the Digitalmars-d-learn
mailing list