4

After I finished writing the following code snippet

With[{values = {-3, 0.3, -0.03, -0.003, 0.003, 0.03, 0.3, 3}},
 Grid[
  Partition[
   Table[
    Block[{b = value},
     Plot[
      b t,
      {t, 0, 100},
      PlotLabel -> Row[{HoldForm[b] -> b}]
      ]
     ], {value, values}], 3, 3, {1, 1}, {}]]]

I realized that b in HoldForm (at PlotLabel -> Row[{HoldForm[b] -> b}]) was highlighted in red and hovering the cursor on top of it produces a tool tip with the text: "b in HoldForm occurs where it is probably not going to be evaluated before going out of scope".

enter image description here A the end of the tool tiop, there is an info button that, when pressed, opens up the documentation of HoldForm.

Can somebody, please, explain to me why am I getting this behavior?

  • 2
    It means exactly what it says. You gave a temporary value to b, then used b in a context where it won't be evaluated. Minimal example (which you should construct yourself next time): Block[{b = 1}, HoldForm[b]]. This is a warning, not an error. It is up to you to decide whether it is relevant (here it's clearly not). – Szabolcs Jan 30 '18 at 09:25
  • 1
    Take a look at: https://mathematica.stackexchange.com/a/633/5478 – Kuba Jan 30 '18 at 09:30
  • I'm voting to close this question as off-topic because the issued raised is not really a Mathemmatica issue, but a misunderstanding of a warning message by the OP. – m_goldberg Jan 30 '18 at 16:15
  • The code editor doesn't know anything about semantics. It only knows about syntax. Just ignore the warning. – m_goldberg Jan 30 '18 at 16:17
  • a workaround (instead of ignoring the error) may be to do bname = HoldForm[b]; before the Block, then do PlotLabel -> Row[{bname -> b}] – george2079 Jan 30 '18 at 17:16

0 Answers0