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

[REBOL] Re: Backwards Navigation on path

From: rotenca:telvia:it at: 12-Oct-2001 17:21

Hi, Volker
> Aother trick: > a: context[ > b: context compose[embedded-in: (self)] > ] > everything you write in brackets in compose > is replaced before makeing the context, > so the (self) is a/self.
If you like object trick, look at this: REBOL [] a1: context[ _self: 'self b: 2 self: context [hidden-in: '_self c: 1] ] prin "this is 'a1 :" probe a1 print ["hidden 'b in 'a1 :" get bind 'b a1/hidden-in] a2: make a1 [d: 2] prin "this is 'a2 derived from 'a1:" probe a2 print ["hidden 'b in 'a2 inherithed from 'a1 :" get bind 'b a2/hidden-in] print "now we set the hidden 'b in 'a1 at 5" set bind 'b a1/hidden-in 5 print "and also the hidden 'b in 'a2 will change:" print ["hidden 'b in 'a2 inherithed from 'a1 :" get bind 'b a2/hidden-in] a3: make a2 [e: 3] prin "this is 'a3 derived from 'a2:" probe a3 print ["hidden 'b in 'a3 inherithed by 'a2 and 'a1:" get bind 'b a3/hidden-in] -- Playing with this 'self sostitution, you can make others "magic" things. For example you can add new hidden words to an intemediate object and make an embedded function which traverse the object hierarchy to find a context which has a value for a given hidden word, and so on.
> -Volker
--- Ciao Romano