Replies: 2 comments
-
I believe this is a duplicate of #201 |
Beta Was this translation helpful? Give feedback.
0 replies
-
I think that what you want is memorization, not entirely sure it has its place in standard library |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
for example
As you can see,
X |> getResult
is called twice. Perhaps it's possible for a cache value to be returned the second timegetResult
is called. Of course we are aware that getResult might have side effect, so maybe there is a way to proof that a function is pure and we only do this for pure function, but I suggest not to erase the side effect of the subsequent calls. This way we can have side effects as we are used to, meanwhile the only problem left is proofing calling the function multiple times will produce the same result. I think as a functional programming language we can do this, by looking at whether a function uses any states that might change. It's not surprising that there are functions that are on the top of a chain of functions that're about to be called and some where in those functions there's a mutable state, but that're also a lot of functions that has record types parameter or is pure functions like algorithms tends to be, I would suggest this as a large case for some optimizations to be looked at.Besides performance, the implication on codes being written is more important for me.
Since functions do a lot things for us, we would like it to be a little bit more verbose by saying what we want to do inside. The obvious way for a programmer is to write it out, and as people are writing out what to do as fluid as it can be, there're going to be things that you are saying to this function that you've already told another function as it's more instinctive coming from a person. So having this feature would encourage people to do that... After we've taken back all the vertical space from C# I would suggest this is a good way to use it
Beta Was this translation helpful? Give feedback.
All reactions