On Tue, 13 Sep 2011 07:43:55 -0400, bearophile
wrote:
Jonathan M Davis:
However, Foo.y is not encapsulated
by a strongly pure function at all. Other functions can alter alter it.
So, it
breaks purity.
Thank you for your explanation :-)
So, let's change the situation a bit. If the stru
On Tuesday, September 13, 2011 07:43:55 bearophile wrote:
> Jonathan M Davis:
> > However, Foo.y is not encapsulated
> > by a strongly pure function at all. Other functions can alter alter it.
> > So, it breaks purity.
>
> Thank you for your explanation :-)
>
> So, let's change the situation a bi
bearophile Wrote:
> So, let's change the situation a bit. If the struct Foo is the only thing
> present in a module (to avoid someone to touch its private members), and the
> y field is "private static" only foo2 is able to touch it. In this case isn't
> foo2 weakly pure?
Weakly pure function
bearophile , dans le message (digitalmars.D.learn:29490), a écrit :
> Jonathan M Davis:
>
>> However, Foo.y is not encapsulated
>> by a strongly pure function at all. Other functions can alter alter it. So,
>> it
>> breaks purity.
>
> Thank you for your explanation :-)
>
> So, let's change th
Jonathan M Davis:
> However, Foo.y is not encapsulated
> by a strongly pure function at all. Other functions can alter alter it. So,
> it
> breaks purity.
Thank you for your explanation :-)
So, let's change the situation a bit. If the struct Foo is the only thing
present in a module (to avoi
On Monday, September 12, 2011 15:24 bearophile wrote:
> A D2 program:
>
>
> struct Foo {
> int x;
> static int y;
> pure void foo1() {
> this.x++;
> }
> static pure void foo2() {
> Foo.y++; // line 8, error
> }
> }
> void main() {}
>
>
> With DMD 2.055 it gives at compile-time:
> test.d(8): Err
A D2 program:
struct Foo {
int x;
static int y;
pure void foo1() {
this.x++;
}
static pure void foo2() {
Foo.y++; // line 8, error
}
}
void main() {}
With DMD 2.055 it gives at compile-time:
test.d(8): Error: pure function 'foo2' cannot access mutable sta