If you could make any changes to D, what would they look like?
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Oct 28 23:21:10 UTC 2021
On Thu, Oct 28, 2021 at 10:48:10PM +0000, Dukc via Digitalmars-d wrote:
> On Thursday, 28 October 2021 at 19:46:32 UTC, Patrick Schluter wrote:
> > Not at all. free cannot, by its semantic, be pure (same for malloc).
> > Trying to make free pure is a silly challenge.
Such a function cannot be strongly pure; at best it can only be weakly
pure. IMO it's a bug that a function that takes an immutable pointer
and frees it can be strongly pure. That breaks the "no visible change to
the outside world" principle of strong purity and invalidates
optimizations based on strong purity.
A weakly pure function rightly cannot be elided in an expression that
calls it multiple times, because weak purity is not strong enough to
guarantee no side-effects.
For every argument for something, there is always an equal and opposite argument against it. Debates don't give answers, only wounded or inflated egos.
More information about the Digitalmars-d