REBOL[]
Inherit: func [super [object!] sub [object!]] [
append sub reduce/no-set [parent: super]
]
Invoke: func [ obj member /local ans] [
either ans: select obj member [
ans
] [
attempt [Invoke obj/parent member]
]
]
Super-Class: context [
Member-A: does [ print "Member-A of Super" ]
Member-B: does [ print "Member-B of Super" ]
]
Sub-Class: context [
Inherit Super-Class Self
Member-B: does [ print "Member-B of Sub" ]
Member-C: does [ print "Member-C of Sub" ]
]
Invoke sub-class 'Member-A
Invoke sub-class 'Member-B
Invoke sub-class 'Member-C
2008年6月9日
OOP in REBOL 3.0: An Example
訂閱:
張貼留言 (Atom)
2 則留言:
有個想法,REBOL 的作者是不是很不喜歡用到 Shift 鍵呀?怎麼都是使用 [ ]?
搞不好是這樣! :-)
張貼留言