wolfram-mathematica - 尝试删除临时符号时出现意外删除::rmnsm 错误

标签 wolfram-mathematica

你好,

考虑以下几点:

In[1]:= HoldComplete[With[{line=a},Null]]
Names["`*"]
Attributes/@Names["`*"]
Remove/@Names["`*"]
Out[1]= HoldComplete[With[{line=a},Null]]
Out[2]= {a,line,line$}
Out[3]= {{},{},{Temporary}}
During evaluation of In[1]:= Remove::rmnsm: There are no symbols matching
"line$". >>
Out[4]= {Null,Null,Null}

可以看到 Remove::rmnsm 消息出现,虽然临时 Symbol line$ 在那一刻仍然存在。为什么会这样?

附言我正在使用 Mathematica 7.01。在 v.5.2 中不会出现此消息。

最佳答案

我认为发生的事情是,当您删除符号 line 时,将不会再引用临时变量 line$,因此它会自动删除。

In[1]:= HoldComplete[With[{line=a},Null]]
        Names["`*"]
        Attributes/@Names["`*"]
Out[1]= HoldComplete[With[{line=a},Null]]
Out[2]= {a,line,line$}
Out[3]= {{},{},{Temporary}}

In[4]:= Remove["line"]

In[5]:= Names["`*"]
Out[5]= {a}

这是在 Mma v8 中测试的。那么也许引用计数(或本地化的实现)自 v5 以来发生了轻微变化?

请注意,如果您首先尝试删除临时符号,您会收到一条信息丰富的警告:

In[6]:= HoldComplete[With[{line=a},Null]]
        Names["`*"]
        Attributes/@Names["`*"]
        Remove/@Reverse@Names["`*"]
Out[6]= HoldComplete[With[{line=a},Null]]
Out[7]= {a,line,line$}
Out[8]= {{},{},{Temporary}}
During evaluation of In[6]:= Remove::relex: Cannot remove lexical symbol 
   line$ except automatically (when line is removed). >>
Out[9]= {Null,Null,Null}

关于wolfram-mathematica - 尝试删除临时符号时出现意外删除::rmnsm 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5713486/

相关文章:

wolfram-mathematica - 仅匹配某些元素的 "children"的模式

unix - 在 Mathematica 后台运行程序

wolfram-mathematica - 加快 ListLinePlot 速度

button - Mathematica : Exporting . 通过按钮的 gif 文件

statistics - 在 Mathematica 中一次绘制不同的条件和主题

list - 模拟 Length 函数以获取列表的长度

regex - Mathematica中的错误: regular expression applied to very long string

matlab - 寻找帐篷 map 的固定点/吸引器/排斥器

wolfram-mathematica - 在 Mathematica 中删除列

keyboard-shortcuts - 如何重新定义 FrontEndEventActions?