What is pure used for?

Imperatorn johan_forsberg_86 at hotmail.com
Thu Nov 25 08:40:17 UTC 2021

On Thursday, 25 November 2021 at 07:26:48 UTC, sclytrack wrote:
> My understanding is that pure is used for compiler optimization 
> in loops and expressions. It leaves out multiple calls if it 
> figures out it is not needed.
> Is pure used for anything else?
> int * pureFunction()
> 1) the pointer needs to be the same.
> 2) the value that the pointer points to needs to be the same. I 
> call this the "value
> of interest" with relation to pure. The pointer doesn't matter.
> 3) both the pointer and the value the pointer is pointing too 
> needs to be the same.
> pureCalloc() satisfies (2)
> pureMalloc() violates everything.
> Does the D compiler do any optimizations?


More information about the Digitalmars-d-learn mailing list