Thanks, Joel,  this worked like a charm.
I was somehow doubty about passing a pointer as an rgument to a rebol 
function... ;-)

Ingo > Thanks to you also. I wanted to use the function because this was 
the structure (a little bit more complex) of my program.

Vincent

Joel Neely a �crit :

>Hi, Arnoux
>
>It's simple (simpler than that, actually ;-)
>
>Arnoux Vincent wrote:
>  
>
>>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
>>]
>>/
>>And output:
>>/probe (first l)/a/
>>/2
>>//probe (second l)/a/
>>/3
>>
>>/Is it possible ?
>>
>>    
>>
>
>Yes, and you don't need the overhead of INC-OBJ or the repeated uses
>of SELF within the method on your objects.  See transcript below:
>
> >> proto: make object! [
>[    count: 0
>[    bump: func [] [count: count + 1]
>[    ]
> >> obj-block: []
>== []
> >> repeat i 4 [append obj-block make proto [count: i]]
>== [
>     make object! [
>         count: 1
>         bump: func [][count: count + 1]
>     ]
>     make object! [
>         count: 2
>        ...
> >> foreach obj obj-block [obj/bump]
>== 5
> >> foreach obj obj-block [print obj/count]
>2
>3
>4
>5
> >>
>
>
>  
>


-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to