Memory allocation purity
via Digitalmars-d
digitalmars-d at puremagic.com
Mon May 19 11:49:41 PDT 2014
On Monday, 19 May 2014 at 18:33:55 UTC, Steven Schveighoffer
wrote:
> Anything that uses the order of unrelated addresses is
> incorrect outside of the heap code itself.
Nah, not on modern archiectures without GC compaction.
> Then you should have no problem producing an example, right?
I did. Besides, I think language constructs should be proven
sound a priori, not post mortem...
> The whole POINT of pure functions is that it will return the
> same thing. The fact that it lives in a different piece of
> memory or not is not important. We have to accept that. Any
> code that DEPENDS on that being in a different address is
> broken.
Which neans you cannot safely plug a pure function into a generic
algorithm unless it testsfor purity.
> For instance, I would consider it fully possible and
> reasonable, and to only break already-broken code (except for
> testing implementation, which would have to change anyway), to
> make idup just return the argument if the argument is immutable.
That could easily break sound code that need guards with
different identities.
More information about the Digitalmars-d
mailing list