DMD 1.038 and 2.022 releases

Simen Kjaeraas simen.kjaras at gmail.com
Wed Dec 17 00:06:43 PST 2008


On Wed, 17 Dec 2008 00:39:00 +0100, Robert Jacques <sandford at jhu.edu>  
wrote:

> On Tue, 16 Dec 2008 12:28:43 -0800, Simen Kjaeraas  
> <simen.kjaras at gmail.com> wrote:
>
>> So this does not seem pure to you?
>>
>>    int myPureFunction(int x) {
>>      return x;
>>    }
>
> Short answer: That's a function, not a delegate and without a 'pure' tag  
> it's unreasonable for the complier to know it's logically pure.

I agree with this, but feel that's beside the point argued by mastrost.
My point (and I believe mastrost's as well) was that the above function
and mastrost's example could be considered pure by the simple addition
of the 'pure' keyword.

> Long answer: Your original arguement was:
>
>> But the fact is that when returning a delegate, its closure freezes  
>> forever and so
> behaves like a local variable and not like a global variable by respect  
> to the
> delegate :
>
> Which I read to mean that a returned delegate is inherently pure. On a  
> second read, I think you mean that the closure heap variables may be  
> treated as immutable once a delegate is returned if the delegate doesn't  
> mutate them. While an interesting observation, it too is easily broken:

Ah, I read it to mean that a delegate with no side effects is just as
pure as a function with none, which I find hard to argue against. As D
is a systems language, one might argue that casting a delegate to pure
is reasonable, as it may be too hard to statically check if it is pure,
and a cast is a confirmation from the programmer that yes, he knows
what he's doing.

-- 
Simen


More information about the Digitalmars-d-announce mailing list