immutable bug?

Manu turkeyman at gmail.com
Sat Jan 11 16:50:18 PST 2014


On 12 January 2014 04:52, Adam D. Ruppe <destructionator at gmail.com> wrote:

> On Saturday, 11 January 2014 at 18:48:15 UTC, Maxim Fomin wrote:
>
>> It is legal exactly because function is marked as pure. Result of pure
>> function is implicitly convertible to immutable.
>>
>
> It shouldn't be here though... the reason it is implicitly convertable is
> that pure means the result is unique.


Can you explain how this is true? I can't see anything about the concept of
purity that suggests the result should be unique...
Pure just means given the same inputs, it will produce the same outputs;
external state can't affect the calculation.

In this case, that's perfectly true. 'this' is just a function arg; it's
not mutated by external state (or at all), given the same this, it will
return the same thing every time.
That doesn't make any claims about what 'this' is though, and whether it's
immutable or 'unique' or whatever. It just promises to transform it in an
identical way given the same inputs...
?

But, with the hidden this pointer having a reference to the data as well,
> it obviously is not unique. I think the compiler should catch this; i'd
> call it a bug.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140112/b13bf484/attachment-0001.html>


More information about the Digitalmars-d mailing list