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
Change name of memoize to cache #70
Conversation
Cache is a more accurate description of what the function does.
How so? |
When an instance of a Future is forked twice there is no guarantee that the result will be the same. Is that not clear? |
Yes, but we're not actually forking, are we? It seems to me we have:
I don't see how this breaks referential transparency (but it's quite possible I've misunderstood the function). |
Lets say I have a file
If I fork both |
I see your point. Changing the name seems like a good idea. Is |
Not really. There is no function that should only be called once. The memoized/cached future can be called several times with different reject/resolve functions. What is done depends on what has been done before. But while we are at it. I am doubtful that this function is actually needed. I added it because I thought we did need it, but I haven't used it so far. We do do caching in our application but I am not sure that caching should be handled by |
merge? |
👍 |
Change name of memoize to cache
I think the problem is the conflation of types. If you want to combine effects like future values and reading files, you need a transformer for this kind of thing: In your example, you're stating that you have a |
@joneshf Is that really correct?
Where is this contract? I have not seen it but I have very much wanted to. Is there a formal definition of Future?
Not sure if I understand what you mean by this but is this not a description of
I had a discussion a while back with @scott-christopher about a
If by "IO" you refer to the |
I was playing around with the idea of I've pushed up what I had so far to a branch if you're interested in having a look: master...scott-christopher:FutureT All the original tests for The previous issues we were having may very well still be present in that branch, as I can't recall what they were. I haven't given it too much time beyond getting most of the tests to pass. |
@scott-christopher master...scott-christopher:FutureT#diff-c5dd7575365ca756ae0970a47f408321R84 If |
Yep, that's right. I wonder if that issue would still exist if we removed the notion of failure being bundled into |
Sounds very interesting, created a dedicated thread... |
I'm not sure if there is for this version of
No, none of these things are the same.
I've said it before, but I'll say it again.
Let me say that again.
In fact...
Oh, and by the way,
While I don't doubt what you say, I also don't understand why it is true. P.S. In case you forgot
|
YES!! This is huge in making code reusable, understandable, and maintainable. |
Because JavaScript is non blocking thus IO operations towards the file system, databases, the network etc. requires the result to be provided in a continuation passing style which is not provided by
This I just find rude. Not sure what your are getting at. |
They're implemented the same way because there is no type system to track effects. The semantics are totally different though.
I apologize, it wasn't meant as a dig on you personally. I was attempting to be funny, but clearly it did not come across as such. What it seems like to me, is that many people get confused about the purpose of |
Ok. cool =) |
Cache is a more accurate description of what the function does.
I recently watched a video with Douglas Crockford where he points out the difference between memoization and caching and I realized that this function is more like the latter. Subsequent calls to the original function will not necessarily yield the same result.