purity question

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 28 18:43:16 PDT 2017


On Sunday, May 28, 2017 18:39:02 Brad Roberts via Digitalmars-d-learn wrote:
> On 5/28/2017 6:27 PM, Jonathan M Davis via Digitalmars-d-learn wrote:
> > There was a whole discussion or 3 is PRs about making malloc pure, and
> > IIRC, it was done and then decided that it wasn't safe to do some for
> > one reason or another (IIRC, it had to do with what would happen when
> > calls were elided, because the caller was strongly pure, but I'm not
> > sure). So, I'd be _very_ careful about deciding that it was safe to
> > call malloc in pure code. I expect that it's just fine in some
> > contexts, but it's easy enough to screw up and mark something as pure
> > when it really shouldn't be because of some detail you missed that you
> > should be _really_ careful about decided to cast to pure.
>
> That's one reason I explicitly referenced malloc/free pairs.  It's a lot
> easier to be sure that those together aren't violating purity.

Agreed. But it's the intricacies like that which make having a clean
backdoor for pure a bit dangerous, much as it would be nice when you
actually need to do it and know what you're doing well enough to get it
right.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list