purity and memory allocations/pointers

Meta jared771 at gmail.com
Sat Aug 3 21:37:58 PDT 2013


On Sunday, 4 August 2013 at 02:05:55 UTC, Timon Gehr wrote:
>> no variables are being modified.
>
> Which I didn't claim. A reference is dereferenced and the 
> contents of the referenced slot are replaced. Then the 
> reference is dereferenced again to read the modified value out.

I'm confused about what your point is now. Are you trying to 
convince me that dereferencing p and modifying the value it 
points to are side-effect free? Of course you can do it in 
Haskell with some wizardry, but D doesn't do any of that.

>> Haskell only simulates side-effects
>
> What tells you that D does not 'simulate' mutable state?

I see what you're getting at. I thought I had a good answer 
before I really thought about your question. I can't think of any 
way to prove that a language is not simply simulating mutable 
state off the top of my head. Do you actually have an answer to 
this question, or were you just making a point?

>> with monads,
>
> What is done to main behind the scenes in order to execute the 
> program is most definitely side-effecting.

I agree with you, but that is done by the runtime in a safe way 
and is mostly out of the user's hands.

>>>> (i.e., the academic definition of purity).
>>>
>>> I wouldn't go that far.
>>
>> Perhaps that may go too far, as academics love to obfuscate 
>> topics with
>> a bunch of extraneous cruft,
>
> I take issue with this statement. I meant, I wouldn't assume 
> 'the academic definition of purity' is a thing.

I don't know what you mean by this. By academic definition, I 
meant the definition of functional purity that is generally 
agreed-upon by the CS academia.

>> but the fact remains that purity means:
>>
>> 1. No modification of local or global state (side-effects)
>> 2. No dependence on global mutable state.
>
> What does this statement quantify over? Eg, where is the 
> abstraction boundary?

Again, can you be more clear? My meaning was that for a function 
to be pure, in a functional programming sense, it must adhere to 
these rules.


More information about the Digitalmars-d mailing list