Skip to content

Function curring is a performance trap? #14943

Answered by En3Tho
Xyncgas asked this question in Q&A
Discussion options

You must be logged in to vote

No, you basically get this for a curried version

let Procedure a =
    fun b ->
      let computation = something a
      another_something computation

You don't enjoy such auto optimizations because of various reasons:

  1. There is no way to know if function is deterministic or not
  2. There is no way to know if function has side effects or not
  3. Even if you kinda think it doesn't have side effects there still might be unexpected ones like allocation. From a function point of view you deterministically return a new object with a certain set of characteristics. But it might still trigger an OOM exception which is obviously a side effect

So I don't believe such optimizations can be applied to the …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Xyncgas
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants