std.functional.memoize : thread local or __gshared memoization?

Timothee Cour via Digitalmars-d digitalmars-d at puremagic.com
Wed May 24 18:17:41 PDT 2017


thanks; i think docs for this should still make that clear.

How about adding memoizeShared for shared variables?
There definitely are use cases for this.


On Wed, May 24, 2017 at 5:19 PM, Jonathan M Davis via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On Wednesday, May 24, 2017 16:56:49 Timothee Cour via Digitalmars-d wrote:
>> I could look at source to figure it out but others might wonder and I
>> couldn't find it in the docs in
>> https://dlang.org/library/std/functional/memoize.html whether memoize
>> works per thread (thread local) or globally (__gshared)
>
> Definitely thread-local, and there would be problems if it were shared,
> since for that to work properly, it would really need to be given either
> shared data or data that implicitly converted to shared. And while __gshared
> might skirt the compiler yelling at you, it would have the same issues; it's
> just that the compiler wouldn't be yelling at you about them, so it would be
> harder to catch them and more likely that you'd get weird,
> hard-to-track-down bugs.
>
> - Jonathan M Davis
>


More information about the Digitalmars-d mailing list