[REBOL] Re: Limitation coming from the "initialize" refinement used with the "Ar
From: ingo:2b1 at: 27-Jun-2002 9:16
Gerard Cote wrote:
> Here is my example code ( I tried it directly at the concole) :
> tab_nbr: array/initial [3 2] 0 cells contents are all initialized to
> the 0 value
> L: 2
> C: 1
> tab_nbr/2/1: 10 cell content [2 1] is updated to 10
> print tab_nbr/:L/:C I verify that all is OK
> tab_nbr/:L/:C: 20 But this one doesn't work, so I
> dynamically generated the real line and asked
> REBOL to execute it.
> The wanted expression was
> : tab_nbr/2/1: 20
> and this can be given by
> join join join join "tab_nbr/" L join "/" C ": " 20
> which generates > "tab_nbr/2/1:
20" then the "do" word will do it like this.
There are a lot of ways to make this work, but sometimes it pays to
think about what arrays really are: blocks of blocks, so the most
elegant solution (IMO) is to use
change at tab_nbr/:L C 20
And, btw, it is _much_ faster:
>> profiler/test [do join join join join "tab_nbr/" L join "/" C ": "
>> profiler/test [change at tab_nbr/:L C 20] 1000000
> While I am at it, I also tried to use the word "reduce" and a to-block
> conversion instead of the word "do" but it seems that the refered object
> (tab_nbr) is not in the same context.
> So is there a way to notify REBOL that we want it to share some valuable
> information from a context to another one or do we have to define it for the
> global one, which in this case is not under my control
Yup, it's 'bind.
>> reduce bind to-block join join join join "tab_nbr/" L join "/" C ":
== [[30 0]]
== [[0 0] [30 0] [0 0]]
'bind has two paramters, the block you want to run in a differrent
context than its default, and a word from the context you want it to run
I hope that helps,
To unsubscribe from this list, please send an email to
unsubscribe" in the