Hi, Elan, now, when curry works, you can get what you deserve 8^)
two variants of the code:
1) - the do calling method proposed by you:
;Function to create methods, adds the hidden SELF argument
meth: func [args body] [
func append copy [self] args body
]
;Function to call methods
!: func [self [object!] 'method [word!]] [
do curry get in self/methods method [self] self
]
;end of %methods.r
;now the example:
a: make object! [
num: 1
methods: make object! [
sumnum: meth [other number] [
switch number [
1 [self/num]
2 [ (do ! other sumnum self 1) + (do ! self sumnum other 1)]
]
]
]
]
b: make a [num: num + 1]
>> do ! a sumnum b 1
== 1
>> do ! b sumnum a 1
== 2
>> do ! a sumnum b 2
== 3
>> do ! b sumnum a 2
== 3
2) the block parameter calling:
;Function to create methods, adds the hidden SELF argument
meth: func [args body] [
func append copy [self] args body
]
;Function to call methods
!: func [self [object!] 'method [word!] param [block!]] [
do append reduce [in self/methods method self] param
]
;end of %methods.r
;now the example:
a: make object! [
num: 1
methods: make object! [
sumnum: meth [other number] [
switch number [
1 [self/num]
2 [ (! other sumnum [self 1]) + (! self sumnum [other 1])]
]
]
]
]
b: make a [num: num + 1]
Both are now functional. What do you vote for?
Ladislav