On Tue, May 13, 2014 at 3:48 PM, Steven D'Aprano <st...@pearwood.info> wrote: > Self-modifying code is a nightmare inside the head of a Lovecraftian > horror. There's a reason why almost the only people still using self- > modifying code are virus writers, and the viruses they create are > notorious for being buggy.
Hmm... what counts as self-modifying, though? When you decorate a function to modify its behaviour (eg add caching around it), all the modification happens at compile time, but it's still executing something other than what you see as the bald code. What about a microkernel that can load altered code from the disk, compile it into memory, and replace portions of itself? I've done that a number of times (not in Python as it has little support for it, but in Pike it's easy); is that self-modifying code? Or a JIT compiler. As you run something, it gets changed in form to be more streamlined. None of these is as horrible as the loop that fiddles with its own code on the fly, but any of them, if buggy, will have the same effect. And all are useful. ChrisA -- https://mail.python.org/mailman/listinfo/python-list