The best you can come up with is exactly what you ask for, it "has an eval function" (as Javier mentioned in his comment on your question).
Self-hosting is not needed, and it does not necessarily do what you want. Two examples: C is a self-service language that cannot execute native code in a string, but Tcl is not a stand-alone language that can execute native code specified in a string.
As a side note, half the time C runs in environments where there is no API to run external processes. Therefore, while in some environments you can configure your system to force C to execute its own compiler and then execute its own code as a whole, this is actually not what you are asking for.
Side note. If we can trick and use the “execute external compiler” route to do this, you don’t need your own hosting to do what you want. It just needs the exec function to call its own compiler (which is often written in C).
The same thing with Reflection / Introspection, which has the ability to do independently on its own, does not mean that you can execute code in a line. Two examples of languages that have Reflection but don't have built-in eval are C # and Java.
- As a side note, once you have the eval function, you can usually do Reflection / Introspection, albeit in an awkward way.
Self-presentation has the same problem with its definition as self-presentation. Tcl is a language where its eval function is not written by itself - it simply provides a Tcl code evaluator implemented in C.
At first glance, meta-circular appraisers look the way you want. It is defined as self-interpretation, where the eval function is built, and not implemented in the language itself. But looking further, you will notice that it is determined by the mechanism used to achieve this function, and not the function itself. Tcl is again an exception where it does not meet all the definitions that meta-circular appraisers, but has an eval function, however (not applicable, not necessary). Therefore, it seems to me that the meta-circular appraiser is a concrete implementation of the "has an eval function" function.
So, I would just say that any language that "has an eval function" can do what you ask for.
slebetman
source share