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

Memoization stdlib #389

Closed
juancarlospaco opened this issue Jun 19, 2021 · 1 comment
Closed

Memoization stdlib #389

juancarlospaco opened this issue Jun 19, 2021 · 1 comment

Comments

@juancarlospaco
Copy link
Contributor

Memoization for functions should be in stdlib.

Basic Memoization is relevant in a function oriented lang like Nim.

Does not have to be the fastest in the world,
an average memoization is still better than no memoization,
can start with a Table-based implementation or similar, can be a macro too.

Should take few lines (~500 lines at most), including a runnableExample.

Memoization should work for JavaScript targets too.

Can provide good performance improvements for very few lines.

Why not implement your own ?

Yes, users can implement a custom one, but then each lib author will do their own,
then in a project with multiple libs the implementations will not be compatible,
that kinda defeats the whole purpose of memoization, 9 caches instead of 1.

How is it done in other langs ?

@Araq
Copy link
Member

Araq commented Jun 20, 2021

There is https://github.com/andreaferretti/memo

Yes, users can implement a custom one, but then each lib author will do their own

You can also use a Nimble package...

that kinda defeats the whole purpose of memoization, 9 caches instead of 1

The cache is usually per function so you would get 9 different caches for 9 different functions, totally acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants