Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.functional.memoize: Ability to clear the cache #10371

Open
dlangBugzillaToGithub opened this issue May 11, 2019 · 1 comment
Open

std.functional.memoize: Ability to clear the cache #10371

dlangBugzillaToGithub opened this issue May 11, 2019 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

aurelien.fredouelle+dlang (@AurelC2G) reported this on 2019-05-11T08:51:53Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=19859

Description

Other common implementations of memoize usually allow to reset the cache. For example, this is quite common in python:

@memoize
def square (x):
  return x*x

square(2)
square(3)

square.cache.clear()

It would be helpful if we could accomplish the same with std.functional.memoize.
@dlangBugzillaToGithub
Copy link
Author

aurelien.fredouelle+dlang commented on 2019-05-12T12:01:54Z

Just tried implementing this by making memoize a struct with a static opCall: https://github.com/dlang/phobos/compare/master...AurelC2G:19859-memoize-cache-clear

However I ran into bug #18289, so this doesn't work as-is.

Any suggestions?

@LightBender LightBender removed the P4 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants