Do pure functions solve the "return const" problems?

Christopher Wright dhasenan at gmail.com
Thu Apr 3 04:35:00 PDT 2008


Janice Caron wrote:
> On 02/04/2008, guslay <guslay at gmail.com> wrote:
>>  If a is not invariant, a can be modified by f().
> 
> Did you mean to say "const" there? If a is not /const/, a can be
> modified by f(). There is no way that f(a) can modify a if a is const.
> That's what const means.
> 
>> However, that is not a side effect: a is considered as an output of f(). f can still called be pure.
> 
> I'd but huge amounts of money on the notion that that's not so.

Pure functions cannot have out or ref parameters?

Ref might be an issue for reference types, since you're supposed to be 
able to memoize based on the bits on the stack passed in as arguments. 
For value types, it's doable.

Out parameters should certainly be supported.



More information about the Digitalmars-d mailing list