Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[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! [ a: 1 b: 2 f1: func [] [print a + b] ] my-api/f1 == 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! [ b: 12 f1: func [] [print a - b] ] But if I apply the patches...... my-api: construct/with third patches my-api does not bind the words as I'd hope: my-api/f1 ** 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 my-api/f1 == -11 ;; the correctly patched result But I am looking for something a little more elegant and/or REBOLish. Any ideas? Thanks, Sunanda.