Closed ferranpujolcamins closed 3 years ago
Agreed. Do you have something in mind? A draft or something?
Yeah, I'll try to come up with something.
Basically I think we can start by explaining what a regular closure is in swift and show how a class that has a function and a property for each captured parameter is isomorphic to a closure.
Then we just need to show that by making the function in our class generic over T, we can now effectively pass around a generic function like an object, i.e. we have created a polymorphic closure.
Sounds good to me. I'm assigning this to you.
Closed by #622
Description
FunctionK allows us to create a class that encapsulates a polymorphic function, thus simulating a closure that is polymorphic on some of its type parameters (rank-n polymorphism). We should add a documentation page explaining this technique.
We should add some example and cover some topics like polymorphic type parameters vs bound type parameters.
Modules
Documentation
Breaking changes
None