--- Comment #13 from 2012-06-03 12:53:36 PDT ---
(In reply to comment #12)
> (In reply to comment #11)
> > Pointers may only access their own memory blocks, therefore exactly those
> > blocks participate in argument value and return value.
> What does 'their own memory block' mean?

The allocated memory block it points into.

> The problem is a pointer is basically an unbounded array,

That is wrong. The pointer is bounded, but it is generally impossible to devise
the exact bounds from the pointer alone. This is why D has dynamic arrays.

> and, if the access isn't restricted somehow, makes the
> function dependent on global memory state.

? A function independent of memory state is useless.

> > But why does it even matter? Isn't this discussion mostly philosophical?
> The compiler will happily assume that template functions are pure even when
> they clearly are not, and there isn't even a way to mark such functions as
> "impure" (w/o using hacks like calling dummy functions etc).
> Example - a function that is designed to operate on arrays, will always be
> called with a pointer to inside an array, and can assume that the previous and
> next element is always valid: 
>   f4(T)(T* p) {
>       p[-1] += p[0];
>    }
> The compiler thinks f4() is pure, when it clearly is not; optimizations based
> on that assumption are likely to result in corrupted data.

f4 _is_ 'pure' (it does not access non-immutable free variables). The compiler
is not allowed to perform optimizations that change defined program behavior.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to