| Thread overview | |||||
|---|---|---|---|---|---|
|
May 21, 2009 It's not always nice to share | ||||
|---|---|---|---|---|
| ||||
http://www.reddit.com/r/programming/comments/8m6p0/dobbs_code_talk_its_not_always_nice_to_share/ | ||||
May 22, 2009 Re: It's not always nice to share | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Fri, 22 May 2009 05:37:42 +1200, Walter Bright <newshound1@digitalmars.com> wrote:
> http://www.reddit.com/r/programming/comments/8m6p0/dobbs_code_talk_its_not_always_nice_to_share/
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'
| |||
May 22, 2009 Re: It's not always nice to share | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Tim Matthews | 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.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply