<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1498" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=270562906-27042005>Hi
all,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=270562906-27042005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=270562906-27042005>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).</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=270562906-27042005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=270562906-27042005>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.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=270562906-27042005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=270562906-27042005>For that reason, I
wonder if this backward compatible enhancement could be considered:
</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=270562906-27042005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=270562906-27042005>* 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.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=270562906-27042005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=270562906-27042005>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.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=270562906-27042005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=270562906-27042005>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.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=270562906-27042005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=270562906-27042005>What do you think?
If it's interesting, I will gladly implement it myself and submit the code for
review.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=270562906-27042005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=270562906-27042005>best
regards,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=270562906-27042005>Vlad</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=270562906-27042005></SPAN></FONT> </DIV></BODY></HTML>