Reputation: 597
After reading that functions are just a special case of closures, being a named constant closure, is there any reason to use a function over a closure? I ran into a problem recently where I needed to pass my functions into a method for sequential animation and ended up needing to transform my functions into closures. So with that disadvantage and loss of flexibility, why would I ever want to use functions over closures?
Upvotes: 2
Views: 102
Reputation: 1310
I advise you to use closures whenever you need to use this code just once and only in that exactly point where you implement it in your whole code.
If you need to reuse the logic of a block of code, the best way is to encapsulate your code inside a function and use it as a callback.
I can´t imagine a situation when you would need to convert all your functions into closures. All you need to do is create a function that fits with your closure signature.
Upvotes: 1