为什么“clear”和“clear”之间的用法存在差异?并“取消设置”;与 Rebol 列表?
给定一个列表:
a: [1 2 3 4 5]
为什么用 clear a
来清除列表,用 unset 'a
来取消设置它?我希望 clear
和 unset
始终采用 a
或 'a
作为参数。
Given a list:
a: [1 2 3 4 5]
Why is it clear a
to clear the list and unset 'a
to unset it? I would have expected both clear
and unset
to consistently take either a
or 'a
as their arguments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Clear 从单词 a 引用的块中删除条目:
Unset 删除单词 a 本身:
Clear removes entries from the block referenced by the word a:
Unset removes the word a itself:
UNSET 是一个采用 WORD 类型值的操作! CLEAR 是一个采用 SERIES 类型值的操作!请注意,多个单词可以指向同一个系列!值...
自从传递一个WORD!目前,将其转换为一系列操作没有任何意义,从技术上讲,CLEAR 可以选择在您向其传递一个 WORD 时进行识别!值,并在这种情况下执行一些特殊操作(例如,查找与该单词关联的值(如果有)并删除其值)。但是“如果没有其他含义,则隐式间接一个单词”并不是一个特别好的不变量,并且您不会在 FIRST 或 FIND 等操作中找到它。
相反的情况......隐式取消设置 QUOTE 其参数。 ..在技术上是可能的。但如果确实如此,当 WORD! 出现时,您将如何处理这种情况!取消设置存储在另一个WORD中?
UNSET is an operation that takes a value of type WORD! and CLEAR is an operation that takes a value of type SERIES! Note that multiple words can point to the same SERIES! value...
Since passing a WORD! into a series operation has no meaning at present, it's technically possible that CLEAR could elect to recognize when you passed it a WORD! value, and do something special in that case (for instance, look up the value associated with that word--if any--and erase its values). But "implicitly indirect a word if there is no other meaning" isn't a particularly nice invariant, and you won't find it in operations like FIRST or FIND etc.
The reverse case... to have unset QUOTE its argument implicitly... would be technically possible. But if it did, how would you handle the case when the WORD! to unset was stored in another WORD?