It's not always nice to share

Walter Bright newshound1 at digitalmars.com
Thu May 21 19:10:37 PDT 2009


Tim Matthews wrote:
> Should this change the way pure functions work. for example:
> 
> module test;
> 
> int i; //tls
> 
> pure void foo(int arg)
> {
>     i = arg;
> }
> 
> void main()
> {
>     foo(2);
> }
> 
> 
>  Error: pure function 'foo' cannot access mutable static data 'i'

No. Pure functions cannot change global state, even if that global state 
is for one thread only.



More information about the Digitalmars-d mailing list