当我尝试使用反射从另一个对象创建 rebol 对象时,为什么会出现错误
>> example: make object! [
[ var1: 10
[ var2: var1 + 10
[ var3: now/time
[ set-time: does [var3: now/time]
[ calculate: func [value] [
[ var1: value
[ var2: value + 10
[ ]
[ ]
>>
>> example2: make object! third example
** Script Error: none is missing its value argument
** Near: calculate: func [value][
var1: value
var2: value + 10
]
>>
如何防止对第三个例子的评估?
>> example: make object! [
[ var1: 10
[ var2: var1 + 10
[ var3: now/time
[ set-time: does [var3: now/time]
[ calculate: func [value] [
[ var1: value
[ var2: value + 10
[ ]
[ ]
>>
>> example2: make object! third example
** Script Error: none is missing its value argument
** Near: calculate: func [value][
var1: value
var2: value + 10
]
>>
How to prevent evaluation of third example ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好的方法可能是使用construct/with——它基于现有对象创建一个对象。
要基于 example 对象加上一个额外字段来创建一个对象:
或者仅使用相同的字段来创建一个对象
Best way is probably to use construct/with -- it creates an object based on an existing one.
To make an object based on the example object plus an extra field:
or to make one with just the same fields
您还可以利用 Rebol 的对象原型:
或者使用附加字段
或替换字段
You could also take advantage of Rebol's object prototyping:
or with additional fields
or replacing fields