purity and memory allocations/pointers

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Aug 3 12:36:26 PDT 2013


On Sat, Aug 03, 2013 at 12:24:08PM -0700, H. S. Teoh wrote:
[...]
> I think a pointer dereference is weakly pure. Consider this:
> 
> 	int func1(int x) pure {
> 		int scratch = x+1;
> 		func2(&scratch);
> 		return scratch;
> 	}
> 
> 	void func2(int* x) pure {
> 		*x = 1;
> 	}
> 
> Clearly, func1 can be strongly pure, because its input will never change
[...]

Gah, I meant its *output* will never change.


T

-- 
This sentence is false.


More information about the Digitalmars-d mailing list