|
How about this for a simple approach? Simply
respect REBOL's insistence on passing by value and
work with it;
>> inc: func[x][x + 1] >> a: 0 ==
0 >> a: inc a ; all one has to do is insert a: , not even one extra
line of code! == 1 >> a == 1 ; a has been incremented as
intended and the script is much clearer! >>
----- Original Message -----
Sent: Thursday, December 16, 1999 10:50
AM
Subject: [REBOL] Passing by reference
Re:(3)
Perhaps this will make more sense to you:
>> a: 0 == 0 >> b: to-set-word 'a == a:
>> ; Note the ":" >> b 1 == 1 >> a
== 1
On Thu, 16 Dec 1999 15:39:51 +0000, [EMAIL PROTECTED] wrote: >Hi Anton, > >Hmmm.
So why doesn't: > > to-set-word b 1
> >work then? What is the difference when you assign
"to-set-word b" to another >word (c) and then use c? Why
does your method work whereas mine doesn't? > >> > Passing by reference
>> >> > a: 0
; >> 0 >> > b: 'a
; >> a >> > to-set-word b
; >> a: >> > to-set-word b 1 ; >>
1 >> > a
; >> 0 >> > >> > so what is the
point of to-set-word if I can then not use it to set the >>
> thing? Do I need an extra block and a "do" or something like that?
>> >> c: to-set-word b >> c 1 >>
a ; >> 1
>> >> Regards >> -- >>
>> Anton >>
|
Chris
Mahnken [EMAIL PROTECTED]
|
|