Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat programming languages will let me manipulate the sequence of instructions in a method?
    primarykey
    data
    text
    <p>I have an upcoming project in which a core requirement will be to mutate the way a method works at runtime. Note that I'm <em>not</em> talking about a higher level OO concept like "shadow one method with another", although the practical effect would be similar.</p> <p>The key properties I'm after are:</p> <ul> <li><p>I must be able to modify the method in such a way that I can add new expressions, remove existing expressions, or modify any of the expressions that take place in it.</p></li> <li><p>After modifying the method, subsequent calls to that method would invoke the new sequence of operations. (Or, if the language binds methods rather than evaluating every single time, provide me a way to unbind/rebind the new method.)</p></li> <li><p>Ideally, I would like to manipulate the atomic units of the <em>language</em> (e.g., "invoke method <code>foo</code> on object <code>bar</code>") and not the assembly directly (e.g. "pop these three parameters onto the stack"). In other words, I'd like to be able to have high confidence that the operations I construct are semantically meaningful in the language. But I'll take what I can get.</p></li> </ul> <p>If you're not sure if a candidate language meets these criteria, here's a simple litmus test:</p> <blockquote> <p>Can you write another method called <code>clean</code> which:</p> <ul> <li><p>accepts a method <code>m</code> as input</p></li> <li><p>returns another method <code>m2</code> that performs the same operations as <code>m</code></p></li> <li><p>such that <code>m2</code> is identical to <code>m</code>, but doesn't contain any calls to the print-to-standard-out method in your language (puts, System.Console.WriteLn, println, etc.)?</p></li> </ul> </blockquote> <p>I'd like to do some preliminary research now and figure out what the strongest candidates are. Having a large, active community is as important to me as the practicality of implementing what I want to do. I am aware that there may be some unforged territory here, since manipulating bytecode directly is not typically an operation that needs to be exposed.</p> <p>What are the choices available to me? If possible, can you provide a toy example in one or more of the languages that you recommend, or point me to a recent example?</p> <hr> <p><strong>Update:</strong> The reason I'm after this is that I'd like to write a program which is capable of modifying itself at runtime in response to new information. This modification goes beyond mere parameters or configurable data, but full-fledged, evolved changes in behavior. (No, I'm not writing a virus. ;) )</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload