Const-correctness and uniqueness. Again.

Kenji Hara via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 9 07:46:29 PST 2015


2015-02-10 0:15 GMT+09:00 via Digitalmars-d <digitalmars-d at puremagic.com>:

> On Monday, 9 February 2015 at 13:19:24 UTC, Tobias Pankrath wrote:
>
>> On Monday, 9 February 2015 at 12:39:06 UTC, Marc Schütz wrote:
>>
>>> It does? Not according to my tests. And it would be bad if it did,
>>> because the returned immutable value could actually reside in read-only
>>> memory.
>>>
>>
>> join returns a mutable array, that can be implicitly casted to immutable
>> if join is pure.
>>
>
> I'm talking about the general case. Jacob seems to be saying that a unique
> _immutable_ value is implicitly convertible to mutable.
>

In general, pure function can access immutable global data, and can return
its address.
Therefore, if a pure function returns immutable data, the returned
pointer/reference to immutable a data should not be convertible to mutable.

Kenji Hara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150210/5394ca63/attachment.html>


More information about the Digitalmars-d mailing list