Memory allocation purity

via Digitalmars-d digitalmars-d at puremagic.com
Thu May 15 03:46:19 PDT 2014


On Thursday, 15 May 2014 at 09:45:52 UTC, Don wrote:
> But it turns out that @memoizable isn't actually an interesting 
> property, whereas '@noglobal' is.
>
> "No global state" is a deep, transitive property of a function. 
> "Memoizable" is a superficial supersetextra property which the 
> compiler can trivially determine from @noglobal.

Uhm. That is a pretty strong assumption. "memoizable" is very 
useful property when you do multihreading, transactions or 
anything that requires locking. And you can still access globals, 
you just need a guarantee that globals don't change until you are 
done.

Considering that > 90% of the functions I write don't do IO or 
globals I'd rather specify the opposite. "io", "global" whatever. 
That is also easy to enforce, i.e. you don't get to access 
IO/globals if you don't annotate the function.


More information about the Digitalmars-d mailing list