这个问题是关于动态地将代码添加到 rebol 2 中的上下文或对象,它与问题Dynamically add words to a context in REBOL有关,但它不是同一类。
如果我想使用它的代码块动态地将代码添加到 rebol 对象,我会因为奇怪的行为而遇到麻烦:
>> append third o [c: 3]
== [a: 1 b: 2 c: 3]
但...
>> first o
== [self a b]
>> second o
== [make object! [
a: 1
b: 2
] 1 2]
>> third o
== [a: 1 b: 2]
附件不见了!如果附加到first o
或相同second o
使用“通用”块不会发生这种情况:
>> m: [a [b] c]
== [a [b] c]
>> append m 3
== [a [b] c 3]
>> m
== [a [b] c 3]
>> append second m 1
== [b 1]
>> m
== [a [b 1] c 3]
为什么是这样?