On Thursday, 15 May 2014 at 15:09:32 UTC, Steven Schveighoffer wrote:
But in this case, you have ignored the rules, […]

Which rules exactly? My point is mainly that this area of the language is underspecified.

This means format("%x", ptr) isn't allowed to be pure?

The short answer would be: Yes. The alternatives seem to be:
 - Disallowing memory allocations in pure code (not workable)
- Bidding farewell to the idea that pure + no mutable indirections means FP-sense purity.

What about calculating index offsets? Note that pointer math between two pointers on the same block of memory is perfectly legitimate.

Taking offsets within the same block are fine. Even in the light of GC allocations being pure, this doesn't lead to any non-determinism, as there isn't any mechanism for the relative offset between whatever you are considering to change without any outside input.

I would expect that someone could be able to write a type equivalent to a slice, and it should be allowed to be pure.

Yes.

David

Reply via email to