The disadvantage of purity

sarn sarn at theartofmachinery.com
Sun Dec 29 10:40:23 UTC 2019


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);
}


More information about the Digitalmars-d mailing list