Mathematica table 错误消息

Mathematica table error messages

以下(省略部分包相关语句):

CartesianMap[ func_, {x0_,x1_,dx_}, {y0_,y1_,dy_} ] = 
  Module[ { x, y, tx, ty, llpx, llpy},
    tx = Table[{Re[func[x + I y]], Im[func[x + I y]]}, 
                  {x, x0, x1, dx}, {y, y0, y1, dy}]; 
    ty = Table[{Re[func[x + I y]], Im[func[x + I y]]}, 
                  {y, y0, y1, dy}, {x, x0, x1, dx}];
    llpx = ListLinePlot[tx];
    llpy = ListLinePlot[ty];
    Show[ llpx, llpy, Axes -> True, AspectRatio -> Automatic, 
                 ImageSize -> Large]
  ]

CartesianMap[ Cos, { 0.2, Pi - 0.2, (Pi - 0.4)/19}, {-2, 2, 4/16}]

当我执行时:

In[99]:= << CartesianMap1.m

我收到以下错误:

During evaluation of In[99]:= Table::iterb: Iterator {x836,x0,x1,dx} does not have appropriate bounds. >>

During evaluation of In[99]:= Table::iterb: Iterator {y836,y0,y1,dy} does not have appropriate bounds. >>

During evaluation of In[99]:= ListLinePlot::lpn: Table[{Re[func[x836+I y836]],Im[func[x836+I y836]]},{x836,x0,x1,dx},{y836,y0,y1,dy}] is not a list of numbers or pairs of numbers. >>

During evaluation of In[99]:= ListLinePlot::lpn: Table[{Re[func[x836+I y836]],Im[func[x836+I y836]]},{y836,y0,y1,dy},{x836,x0,x1,dx}] is not a list of numbers or pairs of numbers. >>

During evaluation of In[99]:= Show::gcomb: Could not combine the graphics objects in Show[ListLinePlot[Table[{Re[func[x836+Times[<<2>>]]],Im[func[x836+Times[<<2>>]]]},{x836,x0,x1,dx},{y836,y0,y1,dy}]],ListLinePlot[Table[{Re[func[x836+Times[<<2>>]]],Im[func[x836+Times[<<2>>]]]},{y836,y0,y1,dy},{x836,x0,x1,dx}]],Axes->True,AspectRatio->Automatic,ImageSize->Large]. >>

**************************************************************
End error messages.
  1. 生成的图形很好。
  2. 问题是在编译时 table 的迭代器是参数,所以没有定义。检查应该在 运行 时间,而不是编译时间。 Wolfram 的糟糕决定。
  3. 在所有语句前加上 Quiet[...] 是丑陋的。
  4. 是否有针对消息的干净解决方案?

函数应该用SetDelayed:=)定义,即

CartesianMap[func_, {x0_, x1_, dx_}, {y0_, y1_, dy_}] :=
  Module[{x, y, tx, ty, llpx, llpy},
  tx = ...