Hey guys, I am pretty sure this must have been discussed here, but it’s difficult for me to properly formulate a headline resp. searching for an existing entry. Hope for your forgiveness.
So I got a function type and it defines some factory function.
To have some adapter pattern I want it to return an interface type.
So the idea is:
For each adapter implementation I just have some factory function that returns a type
implementing the required Adapter interface.
Unfortunately using the concrete factory function only work if I wrap them in an anonymous function.
On the one hand this works, ok.
On the other hand, I do not understand why it works or I don’t understand why my naive attempt to directly use the factory functions does not work.
I put an example here, showing the working and not working version next to each other.
Is this about strictness to enforce well readable code or is this details missing in compiler implementation? To me the code I have to produce unnecessarily verbose.
Bonus: plus points given for the one who tells a more proper topic name.