Memory allocation purity

via Digitalmars-d digitalmars-d at puremagic.com
Thu May 15 05:16:58 PDT 2014


On Thursday, 15 May 2014 at 11:31:34 UTC, Marc Schütz wrote:
> There's an important difference between malloc and new: malloc 
> returns a pointer, but new returns a typed object. This is 
> crucial IMO, because the returned objects are equal to each 
> other.

I most code, but not all, so how does the compiler know if you 
don't have a reference type that explicitly bans identity 
comparison?

If one requires value semantics it should also cover the 
reference.

(Some programs allocate empty objects as "enums".)

> optimization opportunities, but in terms of semantics. For 
> example, you get the concept of uniqueness. And the

I agree that uniqueness is an important property. I think Rust is 
onto something when they now want to rename "mut" to "uniq" or 
"only". But in this case uniqueness is the problem with "weakly 
pure", a problem that "pure functions" don't have.


More information about the Digitalmars-d mailing list