Unofficial wish list status.(Jul 2008)

Walter Bright newshound1 at digitalmars.com
Tue Jul 22 15:18:11 PDT 2008


Sean Kelly wrote:
> Walter Bright wrote:
>> True, but it is not pure. Pure functions cannot change global state.
> 
> The current definition of pure goes even farther than that.  Because 
> arguments to pure functions must be invariant (as far as I know), pure 
> functions may not accept parameters that could be changed by another 
> thread.

That's right. One way to think about it (*) is that for pure functions,
if you take a bit copy of its arguments on the stack, save them, and
some arbitrary time in the future call the function again with those
same bits, you must get back exactly the same result.

> So will D have some way to require that references passed between 
> threads must be either invariant or represent a transferral of 
> ownership?  I think that's the crux of the issue.  Using invariance for 
> non-shared data is typically more for simplifying error recovery than 
> anything else.

Consider (*). Pure functions do not "own" data, as they cannot have state.



More information about the Digitalmars-d mailing list