Hacker News new | past | comments | ask | show | jobs | submit login
Proxy Generic Function (turtleware.eu)
22 points by jackdaniel on Oct 4, 2023 | hide | past | favorite | 2 comments



I don’t get it. Why does this need to be done with such shenanigans. We aren’t allowed to edit the legacy function implementation?


Thanks for asking! You may edit the legacy function implementation. These shenanigans are done to enable providing a new protocol that spans two different set of functions in a way that is a) backward compatible, b) forward compatible.

Say you have functions A and B that do roughly the same, so you refactor them into a function C and then redefine A() { C(); } B() { C(); }. So far good. But if B() is part of the API, some client could have defined auxiliary methods on B - normally they won't be called when C() is invoked directly. Moreover imagine that C() is also now part of the API and some new client could have defined auxiliary methods on C() - normally they won't be called when B() is invoked directly.

So either you need to specify that the old API is obsolete (so old programs doesn't work), or abandon the idea of exporting the new API. With a proxy generic function you may retain the old API and the new API at the same time without further duplicating functionality.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: