Possible to change protocol implementation

First, I wanted to say thank you to everyone in this forum – it has always been a place where very good and useful answers are given. I’m sorry if I do not always respond to the messages!

I had a question about protocols: is it possible to change which protocol implementation to use on the fly at runtime? On a running app, I discovered a bad implementation of a protocol. In iex is it possible to define a new implementation that will take over handling of the data type in question?

1 Like

AFAIK protocols get consolidated into internal tables for faster access on production so IMO no, you can’t.

You can migrate to your own dynamic dispatch by storing MFAs – {module_name, function_name, arguments} – in your runtime configuration. That way you could swap implementations at runtime.