On Sunday, 12 January 2014 at 00:50:30 UTC, Manu wrote:
On 12 January 2014 04:52, Adam D. Ruppe <destructiona...@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.

How could the result not be unique, or at least immutable? Pure functions cannot read mutable global state, so any global state returned must be immutable. Strong pure functions can also only have immutable arguments, so anything returned from those will be immutable. The only other thing that can be returned must be created within the function, which will be unique, and safely converted to immutable.


Reply via email to