Basically, I was curious (a dangerous thing for sure) what language or languages allow you to build up a block of code dynamically to be executed later.
I have looked at http://en.wikipedia.org/wiki/Self-modifying_code I did not find what I was looking for there.
This is not a debate, I am not asking about which one is better than any others. I just want to know which languages contain this programming feature or something similar to it. I would like to see some example code illustrating this feature too if you can.
I have done something similar before in ASP.NET and dynamically built up javascript code to be sent to the page to be executed, or C# generating an SQL query, But never before within the same language. i.e. C# generating C#.
Here is an example of what it could look like (I am writting in a madeup C#/Javaish language)
/ represents a code block escape sequence
CodeBlock codeblock = new CodeBlock();
codeblock+= / print("interesting "); int x = 0; /
for(int i=0; i++; i<10)
{
codeblock+= / for(int i=0; i++; i<10) { x++; Canvas.Draw(new line(x,x+50); } /
}
executionMethod(codeblock);
public void executionMethod(ExecutableCode block)
{
block.exectute();
}