  Self-modifying code has many intriguing applications in a broad range of
fields including software security, artificial general intelligence, and
open-ended evolution. Having control over self-modifying code, however, is
still an open challenge since it is a balancing act between providing as much
freedom as possible so as not to limit possible solutions, while at the same
time imposing restriction to avoid security issues and invalid code or
solutions. In the present study, I provide a prototype implementation of how
one might curb self-modifying code by introducing control mechanisms for code
modifications within specific regions and for specific transitions between code
and data. I show that this is possible to achieve with the so-called allagmatic
method - a framework to formalise, model, implement, and interpret complex
systems inspired by Gilbert Simondon's philosophy of individuation and Alfred
North Whitehead's philosophy of organism. Thereby, the allagmatic method serves
as guidance for self-modification based on concepts defined in a metaphysical
framework. I conclude that the allagmatic method seems to be a suitable
framework for control mechanisms in self-modifying code and that there are
intriguing analogies between the presented control mechanisms and gene
regulation.
