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

[REBOL] Re: object method binding

From: rotenca:telvia:it at: 8-Nov-2001 18:03

Hi, Media
> 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
The second of a function is the real body of the function, with all its binds. you must search in it, copy it and so on. Example: external-variable: 1 weird: make object! [ weird-func: func [][ print external-variable ] ] use [external-variable][ do second get in weird 'weird-func ] --- Ciao Romano