Reputation: 19724
I'm looking for the name of the programming concept that eval
is---eval
being the function which executes a string as an expression.
I'm interested in the term for both executing raw strings in code eval('print("hello")')
, and also from file, like executing any .php
extension. The term I think is appropriate is "runtime metaprogramming" but am looking to know whether this is correct and whether there are other concepts the eval
function presents.
Upvotes: 2
Views: 99
Reputation: 95420
"Interpreter" is a term used for a function that processes a string (provided directly or in a file) representing some kind of program, and returns an answer.
Generally interpreters do not "compile" the string in the process of obtaining its answer. If you know it compiles the string then interpreter isn't really quite the right word and you may simply have to call it an "eval(uator)". (Of course since your example is a black box, you don't really know what it does internally, and people building such tools want them to run fast).
[Metaprogramming is about programs that manipulate other programs, sometimes restricted to "inspecting" other programs. You could argue that your function, to compute its answer, is doing (metaprogramming) "inspection". If you did that, you'd end up lumping classic compiling into metaprogramming which is not a typical view of metaprogramming; usually metaprogramming is about non-compilation/interpretation activities.]
Upvotes: 1