这是至少需要 Rebol 3 的东西:
func [
"Create an object based on some words and values."
words [any-word! block!] "Word or block of words"
values [any-type!] "Value or block of values"
/local object
][
object: make object! either block? words [length? words] [1]
set bind/copy/new :words object :values
object
]
如果您还想允许设置未设置的值,请尝试以下操作:
func [
"Create an object based on some words and values."
words [any-word! block!] "Word or block of words"
values [any-type!] "Value or block of values"
/any "Allows setting words to any value, including unset"
/local object
][
object: make object! either block? words [length? words] [1]
apply :set [bind/copy/new :words object :values any]
object
]
这两个都使用 来创建对象self
,所以如果你想创建一个没有对象的对象,self
你必须做一些更花哨的技巧。有关详细信息,selfless
请参阅提案。