[REBOL] patching an object
From: dhsunanda::gmail::com at: 5-Jul-2007 8:44
Is there an *elegant* way of doing this?
I have an object that makes up an API:
my-api: make object! [
f1: func  [print a + b]
== 3 ;; as you'd expect
But I also have a set of patches that I want to apply
to the API to override various words:
patches: make object! [
f1: func  [print a - b]
But if I apply the patches......
my-api: construct/with third patches my-api
.......it does not bind the words as I'd hope:
** Script Error: a has no value
** Where: f1
** Near: print a - b
One quick fix (given that this currently happens at application
start-up, so I do not need to worry about any persistent values)
is to mold and load:
my-api: first reduce load/all mold my-api
== -11 ;; the correctly patched result
But I am looking for something a little more elegant and/or REBOLish.