July 06, 2011

On 7/6/2011 2:12 PM, David Simcha wrote:
>
>
> On Wed, Jul 6, 2011 at 5:09 PM, Walter Bright <walter at digitalmars.com <mailto:walter at digitalmars.com>> wrote:
>
>     This is what I have difficulty with. Consider:
>
>        pure void foo(int* p) { *p = 3; }
>
>     That isn't pure, or weakly pure.
>
>
> ???? Yes it is.  It can be called from a strongly pure function without violating purity

Yes, but it is not pure itself.

> (Any argument passed to foo is local to the strongly pure function, since the arguments have to be immutable and it can't access mutable global or static variables.)  Isn't that the definition of weakly pure?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20110706/e3537e1d/attachment.html>
July 06, 2011
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20110706/bcb8c59f/attachment.html>
July 07, 2011
On 7/7/11 12:02 AM, Walter Bright wrote:
> On 7/6/2011 2:12 PM, David Simcha wrote:
>> On Wed, Jul 6, 2011 at 5:09 PM, Walter Bright <walter at digitalmars.com
>> <mailto:walter at digitalmars.com>> wrote:
>>     pure void foo(int* p) { *p = 3; }
>> ???? Yes it is. It can be called from a strongly pure function without
>> violating purity
>
> Yes, but it is not pure itself.

So you propose removing the concept of weak purity from the language again? Under the relaxed purity rules (at least in the way I understand them), the function would be pure ? not strongly pure, but you could stick a ?pure? attribute next to it.

David
July 06, 2011
On 2011-07-06 15:02, Walter Bright wrote:
> On 7/6/2011 2:12 PM, David Simcha wrote:
> > On Wed, Jul 6, 2011 at 5:09 PM, Walter Bright <walter at digitalmars.com
> > 
> > <mailto:walter at digitalmars.com>> wrote:
> > This is what I have difficulty with. Consider:
> > pure void foo(int* p) { *p = 3; }
> > 
> > That isn't pure, or weakly pure.
> > 
> > ???? Yes it is. It can be called from a strongly pure function without violating purity
> 
> Yes, but it is not pure itself.

Yes it is. It's weakly pure. Sure, it can't be optimized out on its own, but no weakly pure function can be. It's pure because it does not directly access any global or static variables which can be mutated. Sure, p _could_ be passed a global or static variable, but it doesn't have to be, and it's guaranteed that it isn't when it's called from a strongly pure function (or is in the call chain of a strongly pure function).

With weak purity, all that pure really means is that if the function is in the call chain of a strongly pure function, it cannot access a global or static variable which can be mutated and that it calls no functions which are not themselves pure. It's only when a function is strongly pure that optimizability and the more traditional meaning of purity comes in.

A weakly pure function is a function that when called from a strongly pure will not violate the purity of the strongly pure function. foo would not violate the purity of any strongly pure function which called it. And all weakly and strongly pure functions are pure in that they're marked with the pure modifier (or have it implicitly due to inference by the compiler). So, yes foo _is_ pure. It's _weakly_ pure, but it's pure.

- Jonathan M Davis
July 06, 2011

On 7/6/2011 2:33 PM, Jakob Bornecrantz wrote:
>
> The changes to internal/dmain.d, but it seems that the zips are missing all changes to internal/.
>
>

Fixed.
July 07, 2011
On Thu, Jul 7, 2011 at 1:25 AM, Walter Bright <walter at digitalmars.com> wrote:
> On 7/6/2011 2:33 PM, Jakob Bornecrantz wrote:
>>
>> The changes to internal/dmain.d, but it seems that the zips are missing all changes to internal/.
>>
>>
>
> Fixed.

Confirmed, Thanks!

Cheers Jakob
July 06, 2011
On Jul 6, 2011, at 6:02 PM, Walter Bright <walter at digitalmars.com> wrote:

> On 7/6/2011 2:12 PM, David Simcha wrote:
>> 
>> 
>> 
>> On Wed, Jul 6, 2011 at 5:09 PM, Walter Bright <walter at digitalmars.com> wrote:
>> 
>> This is what I have difficulty with. Consider:
>> 
>>    pure void foo(int* p) { *p = 3; }
>> 
>> That isn't pure, or weakly pure.
>> 
>> ???? Yes it is.  It can be called from a strongly pure function without violating purity
> 
> Yes, but it is not pure itself.

Eek! Walter, I think you have a severe misunderstanding of Don's weak/strong purity concept. Doing a quick google search, I found the following link: http://www.mail-archive.com/digitalmars-d at puremagic.com/msg40808.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20110706/a0367c80/attachment.html>
July 07, 2011
On 7 July 2011 03:12, Jason House <jason.james.house at gmail.com> wrote:
> On Jul 6, 2011, at 6:02 PM, Walter Bright <walter at digitalmars.com> wrote:
>
> On 7/6/2011 2:12 PM, David Simcha wrote:
>
> On Wed, Jul 6, 2011 at 5:09 PM, Walter Bright <walter at digitalmars.com> wrote:
>
>>
>> This is what I have difficulty with. Consider:
>>
>> ? ?pure void foo(int* p) { *p = 3; }
>>
>> That isn't pure, or weakly pure.
>
> ???? Yes it is.? It can be called from a strongly pure function without violating purity
>
> Yes, but it is not pure itself.
>
> Eek! Walter, I think you have a severe misunderstanding of Don's weak/strong purity concept. Doing a quick google search, I found the following link:?http://www.mail-archive.com/digitalmars-d at puremagic.com/msg40808.html

Walter, I don't know what's happened here. You seem to have forgotten
the whole point, somehow.
The whole point of the 'weak pure' concept was that, provided a
function doesn't directly access global variables, it is OK for it to
be called from a strongly pure function.
If a function is weakly pure, that means pretty much nothing. You
can't do any optimization with it, etc.
The one and only thing is gives you, is that it can safely be called
from a strongly pure function.
You seem to be removing weak purity from the language???
July 06, 2011

On 7/6/2011 9:45 PM, Don Clugston wrote:
> On 7 July 2011 03:12, Jason House<jason.james.house at gmail.com>  wrote:
>> On Jul 6, 2011, at 6:02 PM, Walter Bright<walter at digitalmars.com>  wrote:
>>
>> On 7/6/2011 2:12 PM, David Simcha wrote:
>>
>> On Wed, Jul 6, 2011 at 5:09 PM, Walter Bright<walter at digitalmars.com> wrote:
>>
>>> This is what I have difficulty with. Consider:
>>>
>>>     pure void foo(int* p) { *p = 3; }
>>>
>>> That isn't pure, or weakly pure.
>> ???? Yes it is.  It can be called from a strongly pure function without violating purity
>>
>> Yes, but it is not pure itself.
>>
>> Eek! Walter, I think you have a severe misunderstanding of Don's weak/strong
>> purity concept. Doing a quick google search, I found the following
>> link: http://www.mail-archive.com/digitalmars-d at puremagic.com/msg40808.html
> Walter, I don't know what's happened here. You seem to have forgotten
> the whole point, somehow.
> The whole point of the 'weak pure' concept was that, provided a
> function doesn't directly access global variables, it is OK for it to
> be called from a strongly pure function.
> If a function is weakly pure, that means pretty much nothing. You
> can't do any optimization with it, etc.
> The one and only thing is gives you, is that it can safely be called
> from a strongly pure function.
> You seem to be removing weak purity from the language???
>

I put up a new beta with it back in.
July 07, 2011
I found a regression:

http://d.puremagic.com/issues/show_bug.cgi?id=6264

I also found what I think is another one, but I don't have time to reduce it right now.  In other words, if you fix the first one in short order it's probably not worth immediately making another release.  I'll get busy with isolating the second regression tonight.

On 7/7/2011 12:47 AM, Walter Bright wrote:
>
>
> On 7/6/2011 9:45 PM, Don Clugston wrote:
>> On 7 July 2011 03:12, Jason House<jason.james.house at gmail.com>  wrote:
>>> On Jul 6, 2011, at 6:02 PM, Walter Bright<walter at digitalmars.com> wrote:
>>>
>>> On 7/6/2011 2:12 PM, David Simcha wrote:
>>>
>>> On Wed, Jul 6, 2011 at 5:09 PM, Walter Bright<walter at digitalmars.com> wrote:
>>>
>>>> This is what I have difficulty with. Consider:
>>>>
>>>>     pure void foo(int* p) { *p = 3; }
>>>>
>>>> That isn't pure, or weakly pure.
>>> ???? Yes it is.  It can be called from a strongly pure function without violating purity
>>>
>>> Yes, but it is not pure itself.
>>>
>>> Eek! Walter, I think you have a severe misunderstanding of Don's
>>> weak/strong
>>> purity concept. Doing a quick google search, I found the following
>>> link:
>>> http://www.mail-archive.com/digitalmars-d at puremagic.com/msg40808.html
>> Walter, I don't know what's happened here. You seem to have forgotten
>> the whole point, somehow.
>> The whole point of the 'weak pure' concept was that, provided a
>> function doesn't directly access global variables, it is OK for it to
>> be called from a strongly pure function.
>> If a function is weakly pure, that means pretty much nothing. You
>> can't do any optimization with it, etc.
>> The one and only thing is gives you, is that it can safely be called
>> from a strongly pure function.
>> You seem to be removing weak purity from the language???
>>
>
> I put up a new beta with it back in.
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>