On Sat, 05 Apr 2014 08:26:01 -0400, Artur Skawina <[email protected]>
wrote:
On 03/26/14 00:30, Artur Skawina wrote:
It's ok to treat allocator and factory functions as pure, because those
really
are logically pure, ie can't affect any /visible/ state and return
results that
are unique.
That was wrong; treating these funcs as pure won't work. While allocator
functions
have some traits of pure ones -- no side-effects, their result only
depends on the
args, and the call can be optimized out when the result in unused --
there is one
difference, which isn't expressible in D: the uniqueness of the result.
Letting them
be pure would mean that important purity based optimization could not be
allowed
(so that "S* s1 = makeS(32), s2 = makeS(32);" does not break).
I think this still works, even if makeS is pure, since it would be
weak-pure.
-Steve