[Q] Change running code?

Bob Arning arning at charm.net
Thu Jan 30 12:44:43 UTC 2003


On Thu, 30 Jan 2003 12:56:09 +0100 =?iso-8859-1?Q?Tobias_K=E4s?= <tobias.kaes at 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



More information about the Squeak-dev mailing list