Do pure functions solve the "return const" problems?

Janice Caron caron800 at googlemail.com
Wed Apr 2 23:16:47 PDT 2008


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.

>  There is a dependency between the two f(a) that prevents reordering or caching or threading

Then f is not pure.

>  The thing with pure function is that just by looking at the nature of the parameters, you know how coupled they are.

No, the thing with pure functions is, they are not coupled at all.



More information about the Digitalmars-d mailing list