in reply to Re^5: Is modifying the symbol table to redefine subroutines evil?
in thread Is modifying the symbol table to redefine subroutines evil?
To me, it seems a lot less complex than a self-modifying program.
Oh wait... self-modifying? In what sense? All the code there is, is there in the first place. As with the OP's code, we are talking of a named sub, whose code reference is replaced by an anonymous subroutine at the first call of that named sub. The code block for that anonymous subroutine reference is inside the named sub, and it is called at the first call of that named sub, and at all calls of that sub thereafter.
No code is generated, and no code is modified at runtime. There's a conditional that is optimized away, not by the perl interpreter but explicitly by the programmer.
If we would label that coding as writing a self-modifying program, then using e.g. POSIX would also comprise writing a self-modifying program - and all programs that use the AutoLoader, and all programs that pull in any module via use, require or do file.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Is this evil?
by perrin (Chancellor) on Apr 12, 2007 at 21:29 UTC | |
by shmem (Chancellor) on Apr 12, 2007 at 21:35 UTC |