On Thu, 30 Jan 2003 12:56:09 +0100 =?iso-8859-1?Q?Tobias_K=E4s?= tobias.kaes@gmx.de wrote:
Does anyone know what happens, if the implementation of a method is changed while it is executed? I'm interested inÊhow dynamic systems handle such situations, so if you know how it is done here, or have any ideas how it could be solved please tell me :)
Changes to method implementation take effect when that method next begins execution. If the method was already running when the implementation changed, it will continue to run with the old version. If you want to change methods that are running, the general solution is to refactor the code so that the method returns and is restarted frequently. So, rather than one method with a loop: ---------- main
[ self doThis. self doThat. ] repeat ----------
you would do something like
---------- main
[self innerLoop] repeat ---------- innerLoop
self doThis. self doThat. ----------
This would allow you to change the implementation of innerLoop and have that change take effect sooner.
Cheers, Bob
Bob Arning arning@charm.net appears to have written:
On Thu, 30 Jan 2003 12:56:09 +0100 =?iso-8859-1?Q?Tobias_K=E4s?= tobias.kaes@gmx.de wrote:
Does anyone know what happens, if the implementation of a method is changed while it is executed? I'm interested inÊhow dynamic systems handle such situations, so if you know how it is done here, or have any ideas how it could be solved please tell me :)
Changes to method implementation take effect when that method next begins execution. If the method was already running when the implementation changed, it will continue to run with the old version.
Within Squeak this is true. In a system with some variety of dynamic translation it may not be entirely true, it will depend on the details of the way things are cached. For example if a method is translated and a pointer to that translation is held in some inline cache entry in a calling method then one would have to make sure that the system correctly flushes that caching when the subject method is recompiled. Typically some primitive is called by the compiler code to do this. At least, one hopes that it is :-)
tim
squeak-dev@lists.squeakfoundation.org