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

[REBOL] object method binding

From: media::quazart::com at: 8-Nov-2001 9:52

Hello world, a question for context/binding experts how do I re-define a method'd function so that it uses a variable defined in the original function but which does not access data within the object itself, and which its binding is unknown? for example: I know of the existence of the following object: weird: make object! [ weird-func: func [][ print external-variable ] ] the problems is: ---------------- Because the code was built within a dynamic loop, at the time of creation, external-variable WAS defined so rebol linked (or bound?) that word to whatever it meant at that time. but as you see, it does not reference a value within weird itself but rather a value that it linked outside of weird, so somehow its still valid, but we do not know exactly what external-variable "points" to... Now the question: -------------------- how can I replace the weird method to another function but still use the original's external-variable value... like if I wanted to do my-extension: "ext" extended-weird: func[][ print ["I have extended" external-variable my-extension] ] weird/func: :extended-weird ... of course the above WILL fail ... in the context of this problem, there is simply no way to trap the original definition of weird, so that I can create a global to re-assign external-value in my own function... ain't context and binding fun!!? Thanks in advance! -Maxim