Proposal: Relax rules for 'pure'

Robert Jacques sandford at jhu.edu
Thu Sep 23 15:39:53 PDT 2010


On Thu, 23 Sep 2010 16:35:23 -0400, Tomek Sowiński <just at ask.me> wrote:
>
> On topic: this means a pure function can take a reference to data that  
> can be mutated by
> someone else. So we're giving up on the "can parallelize with no  
> dataraces" guarantee on
> pure functions?
>

In short, No. In long; the proposal is for pure functions become broken up  
into two groups (weak and strong) based on their function signatures. This  
division is internal to the compiler, and isn't expressed in the language  
in any way. Strongly-pure functions provide all the guarantees that pure  
does today and can be automatically parallelized or cached without  
consequence. Weakly-pure functions, don't provide either of these  
guarantees, but allow a much larger number of functions to be  
strongly-pure. In order to guarantee a function is strongly pure, one  
would have to declare all its inputs immutable or use an appropriate  
template constraint.


More information about the Digitalmars-d mailing list