OpenersNotesSection(Spacer1)Details

OpenersPrimaryExamplesSection(Spacer1)Examples  (5)

OpenersExampleSection0(Spacer1)Basic Examples  (5)

Interpret expressions and avoid evaluation:

Interpreter["HeldExpression"]["1/2 + 3/5 - 2/3"]

Interpreter["HeldExpression"]["Cos[Pi]"]

No evaluation is attempted when matching the choices:

Interpreter[Restricted["HeldExpression",{{1,2,3,4}}]]["2+1"]

Interpreter[Restricted["HeldExpression",{{2, HoldComplete[2+1]}}]]["2+1"]

By default, only expressions with no side effect are allowed:

Interpreter["HeldExpression"]["Quit[]"]

This can be changed by allowing (RefLink[All, paclet:ref/All]) symbols:

Interpreter[Restricted["HeldExpression", All]]["Quit[]"]

Restrict to a list of symbols:

Interpreter[Restricted["HeldExpression",{Map,List,Function,Slot}]]["#&/@{1,2,3}"]

Interpreter[Restricted["HeldExpression",{Map,List,Function,Slot}]]["#+1&/@{1,2,3}"]

By default, new symbols are created in (RefLink[$Context, paclet:ref/$Context]), but a custom context can be specified:

Interpreter[Restricted["HeldExpression",Automatic,Automatic,Automatic]]["x"]
Context[x]

Interpreter[Restricted["HeldExpression",Automatic,Automatic,"mycontext`"]]["y"]
Context[y]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Interpreter, paclet:ref/Interpreter])  ▪  (RefLink[Restricted, paclet:ref/Restricted])  ▪  (RefLink[Failure, paclet:ref/Failure])  ▪  (RefLink[HoldComplete, paclet:ref/HoldComplete])}, {Related Interpreter Types:  (RefLink[Expression, paclet:ref/interpreter/Expression])  ▪  (RefLink[InactiveExpression, paclet:ref/interpreter/InactiveExpression])  ▪  (RefLink[SemanticExpression, paclet:ref/interpreter/SemanticExpression])  ▪  (RefLink[HeldSemanticExpression, paclet:ref/interpreter/HeldSemanticExpression])  ▪  (RefLink[InactiveSemanticExpression, paclet:ref/interpreter/InactiveSemanticExpression])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Setting Up Input Interpreters, paclet:guide/InterpretingStrings])}})}})