[REBOL] Re: Limitation coming from the "initialize" refinement used with the "Ar
From: lmecir:mbox:vol:cz at: 27-Jun-2002 8:49
Hi Gerard,
instead of
tab_nbr/:L/:C: 20
which doesn't work you can use:
1)
change at at tab_nbr L C 20
2)
change at tab_nbr/:L C 20
3)
poke tab_nbr/:L C 20
I do not suggest you to use string conversion, because it doesn't preserve
the context information. If you insist on doing it your way, you should use
blocks instead of strings as follows:
do reduce [to set-path! reduce ['tab-nbr L C] 20]
----- Original Message -----
From: "Gerard Cote"
Hello,
As I tried to generate a dynamic line of code to create a way to circumvent
the way REBOL interprets the ARRAY notation when used with variable indexes
instead of numeric constants (nothing really hard with REBOL), I found some
limitation with the initialize refinement as following : It seems only
possible to use the same constant (a scalar value or any other datatype
seems to be is accepted) as the initial value used by the Array word itself.
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.
do join join join join "tab_nbr/" L join "/" C ": " 20
But now that I can use real variable indexes with my array, am I supposed to
use loops too just to get
any cell value initialized with something other than some constant like the
series of values : 10, 20 , 30 , 40 50 and 60.
Would it not be simpler to have something like this :
tab_nbr: array/initial/series [3 2] 10 60 10 where the start, stop and
increment values would be respectively 10 60 and 10.
IS this already possible in another way that I am not aware of ?
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
Thanks to all for any clue if any,
Gerard