[REBOL] Re: Newbie: need help with COMPOSE
From: ingo:2b1 at: 13-Oct-2003 13:22
Hi Arie,
this doesn't look like the most elegant way to do it to me, but it works ...
;--- start script ---
[REBOL []
;
; This function extends a 2nd level object with a function
;
add-affix-func: func [
/local fxn "don't know, wether you need fxname to be a string ..."
] [
fxn: to-word fxname
do compose/deep [
(to-set-path compose [rules (fxn)])
make (to-path compose [rules (fxn)]) [
(to-set-word join 'rule fxcount) func [
inword [string!]
][
print 200
]
]
]
]
;
; Main program starts here
;
fxname: "A" ; name of 2nd level object
fxcount: 1 ; counter
rules: make object! [] ; create 1st level object
do probe compose/deep [
rules: make rules [ ; create 2nd level object
(to-set-word fxname) make object! [ x: 100 ]]
]
probe rules ; show intermediate result
;input ; pause console
add-affix-func ; extend 2nd level object
probe rules ; show final result
;input ; pause console
]
Arie van Wingerden wrote: