我创造了这个
cloneset: :set
set: func[word [word!] value][
if/else (type? get word) = list! [
print "list is immutable"
][
cloneset word value
protect word
]
]
protect 'cloneset
protect 'set
Run Code Online (Sandbox Code Playgroud)
使用新的set函数定义val函数时出现此错误:
val: func[word [word!] value][
set word value
protect word
value
]
>> val: func[word [word!] value][
[ set word value
[ protect word
[ value
[ ]
** Script Error: set has no refinement called any
** Where: throw-on-error
** Near: if error? set/any 'blk try
Run Code Online (Sandbox Code Playgroud)
我不明白为什么?
当您重新定义定义的单词时system/words,您应该完全重新定义它.该set字有两个改进:/pad和/any你重新定义还应该包括:
cloneset: :set
set: func [
word [word! block!]
value
/any
/pad
][
either all [word? word list? get word] [
throw make error! "List is immutable!"
][
comment {
At this point you'll have to forward the arguments and refinements
of your SET method to CLONESET. This will be made much easier in R3
with the new APPLY function.
}
]
]
Run Code Online (Sandbox Code Playgroud)
(我根本没有测试过上面的代码.它应该被视为伪代码.)
| 归档时间: |
|
| 查看次数: |
172 次 |
| 最近记录: |