[Issue 12387] Mark stdlib malloc and friends as weekly pure

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 20 08:06:24 PDT 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12387


Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy at yahoo.com


--- Comment #4 from Steven Schveighoffer <schveiguy at yahoo.com> 2014-03-20 08:06:18 PDT ---
(In reply to comment #2)
> Could you please explain what makes GC "special", but not "malloc" ? What does
> one need to verify to be "special".

C malloc is not any less special than GC.malloc. it could technically be marked
weak-pure. I think Walter is confusing purity with strong purity. Malloc is not
strong-pure, and would not be considered as such (it returns mutable pointer).
It is the classic example of weak purity.

> Also related: If malloc is not pure, then there is *0* chance of seeing much
> use of it outside the IO module. We have gone through great lengths to keep
> most range/algorithm/string functions pure and CTFE-able. Breaking that purity
> is *NOT* acceptable.

I agree, I think this enhancement should be reconsidered. Any allocation scheme
that globally stores "unused" blocks should be considered logically pure, and
therefore can be forced pure. You treat the storage area as not really existing
before it's requested, so accessing that global pool isn't technically
accessing global state.

It isn't any different than asking the OS to supply the blocks, which should
also be considered pure.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list