Memory allocation purity

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Thu May 15 14:22:41 PDT 2014


On 05/15/2014 07:41 PM, Steven Schveighoffer wrote:
>>
>> Not really, allocation is just an implementation detail. The
>> computational language is meaningful independent of how you might
>> achieve evaluation of expressions. I can in principle evaluate an
>> expression of such a language on paper without managing a separate
>> store, even though this usually will help efficiency.
>>
>> Functional programming languages are not about taking away features
>> from a procedural core language. They are based on the idea that the
>> fundamental operation is substitution of terms.
>
> But they do not deal in explicit pointers.

(Well,

http://hackage.haskell.org/package/base-4.7.0.0/docs/Foreign-Marshal-Alloc.html#v:malloc 
)

> Otherwise, that's a can of
> worms that would weaken the guarantees, similar to how D's guarantees
> are weakened.
> ...

The concept of a 'pointer' to some primitive value does not have a 
meaning in such languages. Every value is an "rvalue".

> We have no choice in D, we must accept that explicit pointers are used.
> ...

We could e.g. ban comparing immutable references for identity / 
in-memory order.

>>> To be honest, code that would exploit such an anomaly is only ever used
>>> in "proof" exercises, and never in real code.
>>
>> Hashtables are quite real.
>
> Pretend I'm ignorant, what does this imply?
> ...

E.g. order of iteration may be dependent on in-memory order of keys and 
the 'same' keys might occur multiple times.

>> This is the issue:
>>
>> On Thu, 15 May 2014 10:48:07 +0000
>> Don via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
>>>
>>>> Yes. 'strong pure' means pure in the way that the functional
>>>> language crowd means 'pure'.
>>>> 'weak pure' just means doesn't use globals.
>>
>> There is no way to make that claim precise in an adequate way such
>> that it is correct.
>
> This doesn't help, I'm lost with this statement.
>
> -Steve

The issue is that there are apparently different expectations about what 
the keyword is supposed to do.



More information about the Digitalmars-d mailing list