"InactiveExpression" (Interpreter Type)
Wolfram Language expression.
Details
- "InactiveExpression" can be used in Interpreter and related constructs, including deployed smart form fields.
- Use of "InactiveExpression" does not require connectivity to the Wolfram Cloud.
- "InactiveExpression" keeps its result unevaluated by wrapping it in Inactivate.
Restriction Specifications
-
Restricted["InactiveExpression",{{choice1,…}}] one among choices Restricted["InactiveExpression",symbols] an expression involving only the given symbols (All, Automatic, or an explicit list) Restricted["InactiveExpression",symbols,contexts] an expression involving only the given symbols or symbols in the given contexts (All, Automatic, or an explicit list) Restricted["InactiveExpression",symbols,contexts,resultcontext] an expression involving only the given symbols or symbols in the given contexts, where the new symbols are created in resultcontext
Interpretation
- "InactiveExpression" yields an Inactive Wolfram Language expression.
Examples
Basic Examples (7)
Interpret expressions and avoid evaluation:
Interpreter["InactiveExpression"]["Sin[Pi/2]"]Interpreter["InactiveExpression"]["3+2"]No evaluation is attempted when matching the choices:
Interpreter[Restricted["InactiveExpression", {{1, 2, 3, 4}}]]["2+1"]Interpreter[Restricted["InactiveExpression", {{2, Inactivate[2 + 1]}}]]["2+1"]By default, only expressions with no side effect are allowed:
Interpreter["InactiveExpression"]["Quit[]"]This can be changed by allowing All symbols:
Interpreter[Restricted["InactiveExpression", All]]["Quit[]"]Restrict to a list of symbols:
Interpreter[Restricted["InactiveExpression", {Map, List, Function, Slot}]]["#&/@{1,2,3}"]Interpreter[Restricted["InactiveExpression", {Map, List, Function, Slot}]]["#+1&/@{1,2,3}"]By default, new symbols are created in $Context, but a custom context can be specified:
var = Interpreter[Restricted["InactiveExpression", Automatic, Automatic, Automatic]]["x"]
Context[Evaluate[var]]var = Interpreter[Restricted["InactiveExpression", Automatic, Automatic, "mycontext`"]]["x"]
Context[Evaluate[var]]Specify contexts for the allowed and output symbols:
mycontext`x = 10;
Interpreter[Restricted["InactiveExpression", Automatic, {"mycontext`", "System`"}, "mycontext`"]]["y = x + 1"]Prevent the creation of any new symbol:
Interpreter[Restricted["InactiveExpression", Automatic, Automatic, None]]["3+1"]Interpreter[Restricted["InactiveExpression", Automatic, Automatic, None]]["z+1"]See Also
Interpreter Restricted Failure Inactive Inactivate
Interpreter Types: Expression HeldExpression SemanticExpression HeldSemanticExpression InactiveSemanticExpression
Related Guides
History
Introduced in 2014 (10.0)