The disadvantage of purity
Dominikus Dittes Scherkl
dominikus at scherkl.de
Sun Dec 29 10:47:33 UTC 2019
On Sunday, 29 December 2019 at 10:40:23 UTC, sarn wrote:
> On Sunday, 29 December 2019 at 10:02:48 UTC, berni44 wrote:
>> I have not yet a deep understanding of purity, so maybe there
>> is a way arround this problem I cannot see due to my limited
>> knowledge. Any ideas?
>
> Here's a generic pattern you could use:
>
> T foo(Value x) pure
> {
> static T impl(Value x, ref State s) pure
> {
> // ...code recursively calling impl and tracking state with
> mutable s
> }
> State s;
> return impl(x, s);
> }
Yes, exactly this.
More information about the Digitalmars-d
mailing list