尝试删除临时符号时出现意外的删除::rmnsm 错误
美好的一天,
请考虑以下事项:
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$
在那一刻仍然存在。为什么会出现这种情况?
PS 我正在使用 Mathematica 7.01。在 v.5.2 中,此消息不会出现。
Good day,
Consider the following:
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}
One can see that Remove::rmnsm
message appear although the temporarySymbol
line$
still exists up the that moment. Why this happens?
P.S. I am using Mathematica 7.01. In v.5.2 this message does not appear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为发生的情况是,当您删除符号
line
时,就没有对临时变量line$
的进一步引用,因此它会自动删除。这已在 Mma v8 中进行了测试。那么自 v5 以来,引用计数(或本地化的实现)可能略有变化?
请注意,如果您尝试先删除临时符号,您会收到一条信息丰富的警告:
I think what is happening is when you remove the Symbol
line
then there are no further references to the temporary variableline$
and so it is automagically removed.This was tested in Mma v8. So maybe the reference counting (or the implementation of localization) has changed slightly since v5?
Note that if you try to remove the temporary symbol first, you get quite an informative warning: