Dynamic method replacement

Hi, @Arnold thanks for making this proposal.

Full disclosure I have worked some time ago on a proposal that aims to add features that are similar to this one, but I think in a more secure and controlled way.

FWIW I'm firmly against this approach because most of the time method swizzling is abused mainly by third-party and it makes you lost control of how your code or the code you are working with operate. There are issues from prioritizing witch implementation win to how to protect my code against this approach. I have lost so much time debugging/patching issues introduced by another library swizzled code that thinking about adding this kind of feature in Swift scares me a bit.

On the bright side, I think we can have the same feature by using an Aspect Oriented Programming approach the wrap behavior is the one that allows you to manipulate the output of a function.

@dabrahams can you please explain what resilience is?

@Rod_Brown I have developed libraries for a long time, and I'm against doing magic tricks behind the developer's back I instead prefer always to give them all the tools they might need to work with and if there is a bug I prefer to fix it myself and re-ship the lib.

@Karl we can install hooks with an Aspect Oriented Programming approach

4 Likes