【发布时间】:2023-04-02 22:58:02
【问题描述】:
有人说你可以使用 get 与 Rebol 一起(实现继承)。所以我尝试了:
shape: context [
x: 0
y: 0
draw: func['object][
probe get object
]
]
circle: make shape [
radius: 10
draw: get in shape 'draw
]
rectangle: make shape [
draw: get in shape 'draw
]
我想通过引用而不是值来传递对象,所以我只使用 'Object.但后来我不得不这样称呼它
circle/draw 'circle
这是相当蹩脚的,因为我需要重复两次名称 circle 而在通常的继承中,有 this 关键字可以避免这种不自然的语法。有没有更优雅的方式?
谢谢。
【问题讨论】:
标签: rebol