這個問題是關於動態添加代碼到上下文或rebol 2中的對象,它與問題Dynamically adding words to a context in REBOL有關,但它不是同一種類。爲什麼不動態添加代碼到對象在Rebol2中生效?
如果我想使用它的代碼塊我遇到了麻煩,由於怪異的行爲得到了動態代碼添加到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]
這是爲什麼?