Consider a programming language which permits calling functions to start running (have an entry point) at any point in the function, controlled at the call site. Perhaps more radically, the call site can perform arbitrary code manipulations on a function before calling it. It probably needs to be an interpreted language.
Slightly tricky might be to define the function type signature for such modified calls.
This decreases the need to refactor, or at least the for the function/library author to refactor: the caller -- the function caller -- can do the refactoring. A demo program can quickly be reused as a library.