Code lifecycle (suggestion)

Vlad Dumitrescu XX (LN/EAB) vlad.xx.dumitrescu@REDACTED
Wed Apr 27 08:42:51 CEST 2005


Hi all,
 
I was trying to implement an utility to transparently memoize a module's exported functions (this means that a wrapper is built around them and the wrapper remembers the results of previous calls, who don't need to be recomputed again).
 
I think I have a nice solution, but since it involves a hidden module, I stumbled on a problem: if the original module's code is reloaded (or upgraded) then the whole thing breaks apart.
 
For that reason, I wonder if this backward compatible enhancement could be considered: 
 
* for modules declaring -behaviour(lifecycle), let the code loader look for a lifecycle/1 function and call it before and after loading/purging the code. The argument could be before_load, after_load, before_purge, after_purge.
 
This way, initialization and cleanup could be handled nicely. I think even other applications might find this mechanism useful and it is also extensible if needed.
 
I'm not sure if there won't be any clashes when both old and new code is running on a system, but hopefully nothing that can't be avoided with little care.
 
What do you think? If it's interesting, I will gladly implement it myself and submit the code for review.
 
best regards,
Vlad
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20050427/fa05e8e2/attachment.htm>


More information about the erlang-questions mailing list