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

[REBOL] Re: [Fwd: Accessing a variable's method]

From: ingo:2b1 at: 10-Oct-2003 18:04

Hi Arnoux, Arnoux Vincent wrote:
> A few anti-slashes have been added (dunno know why...) : > > Hi List, > I have a list of objects: > l: copy [] > obj: make object! [ a: none calc: does [self/a: (self/a + 1)]] > append l make obj [a: 1] > append l make obj [a: 2] > > I would like to write a function like: > inc-obj: func [arg][ > arg/calc > ] > > That would allow me to do: > foreach o l [ > inc-obj o > ]
Up to here, no problem. (though I don't know why you don't want to use foreach o l [ o/calc ]
> And output: > probe (first l)/a > 2 > probe (second l)/a > 3
But this won't work, because parens!s are not allowed in paths ... however you can do any of the following ... probe l/1/a == 2 probe l/2/a == 3 num: 1 probe l/:num/a == 2 and becoming somewhat esoteric ... probe get in first l 'a == 2 I hope that's enough for now ... Ingo