[Q] Change running code?
Bob Arning
arning at charm.net
Thu Jan 30 13:44:43 CET 2003
On Thu, 30 Jan 2003 12:56:09 +0100 =3D?iso-8859-1?Q?Tobias_K=3DE4s?=3D =
<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=CAhow 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 :)=20
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
|