WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

Define a held expression that refers to the variable x:

Because Hold has the attribute HoldAll , x is not evaluated when the held expression is defined, so the body of the expression refers to the global variable x. The value of x is obtained when the Hold is released:

To effectively force x to evaluate when the held expression is defined, use With :

Now changes in the value of x have no effect on the value returned when the Hold is released:

Notes

This technique applies to any function with HoldAll , HoldFirst , HoldRest or HoldAllComplete attributes, for example, Function itself:
Evaluate can be used to resolve a variable to its value in a held argument, but only when it occurs at the top level of the argument. Compare:

Related Functions

With   HoldAll   HoldFirst   HoldRest   HoldAllComplete   Hold   Function   Evaluate

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /