Erin at rebol.com was generous in his response
to my problem repeated below:
-----------------
Note: Symbols on the console may be deceptive.
s: "some text" ===> 'some text"
reduce 's ===> s ; (first s )
print (reduce 's) ===> s ; (second s)
reduce ['s] ===> [s] ; (third s )
These 3 s symbols look the same on the console but are all different.
So, though (reduce 's) appears to give s, it is not the same s
which the console will use if we enter: print s ===> some text
or do reduce ['s] ===> "some text"
------------------------------------------------------------------------------------------
end of problem statement - start of Erin's reply
------------------------------------------------------------------------------------------
Let's see what I have here:
rbl> s: "some text"
== "some text"
Okay, so the word 'S is referencing "some text":
rbl> reduce 's
== s
Reducing a word litteral always results in a word litteral.
Whether or not it's defined. For instance:
rbl> t
** Script Error: t has no value.
** Where: t
rbl> reduce 't
== t
rbl> type? 't
== word!
rbl> type? reduce 't
== word!
Notice the TYPE? both on the plain litteral and the reduced
litteral 'T? In both cases it's word!. REDUCE is not changing
the value of 'T at all, it's quite the same as if doing a reduce
on an integer.
rbl> print (reduce 's)
s
This is the same as just REDUCE 'S. The litteral, 'S, is being
passed to PRINT, which is doing another REDUCE on the litteral
before doing a FORM.
Now, going a bit deeper, what's actually happening is REDUCE
is passing the reference to S. Since S isn't, at this point,
directly expressed, it evaluates to it's word litteral. The way
to get the value of S after passing its litteral as a value is
using GET:
rbl> print get (reduce 's)
some text
Now the question of word litterals in blocks:
rbl> reduce ['s]
== [s]
This causes the block to be reduced. Since a word litteral is
used in this block, this litteral will be reduced to the word it
represents, litterally. This is unlike passing the word litteral
reference as seen above, as the litteral's reference to the word
S is reduced, in this case, to just the word S. So, if reduced
a second time:
rbl> reduce reduce ['s]
== ["some text"]
There you have it.
The reason the behavior is different between reducing a litteral
in a block and a word litteral directly is this.
Reducing a word litteral directly returns a reference to the word.
So, continued operations on this reference continue to operate on the
reference, not the word itself, unless a GET is used.
Reducing a block returns a reference to the reduced block. Since a
word litteral is not directly expressed in this way, it's reference
is returned in the reduced block.
So, to make things a little clearer, we can asign 'S to X and do
some of what was done above:
rbl> x: 's
== s
12:01:09 rbl> reduce x
== s ; passes the reference to S
12:01:17 rbl> reduce reduce x
== s ; just keeps passing the reference to S
rbl> get x
== "some text" ; gets X's reference to S and returns the value of S
12:01:20 rbl> reduce [x]
== [s] ; the reference to S is returned in the reduced block
12:01:25 rbl> reduce reduce [x]
== ["some text"] ; that reference to S can now be evaluated
> These 3 s symbols look the same on the console but are all different.
> So, though (reduce 's) appears to give s, it is not the same s
> which the console will use if we enter: print s ===> some text
> or do reduce ['s] ===> "some text"
Nope, the three symbols are the same, just used in different ways.
I'll look into clarifying this in the manual, thanks for pointing
it out.
Cheerfulness,
Erin Thomas <[EMAIL PROTECTED]>
------------------------------------------------------------------------------------------------
end of Erin's reply
-----------------------------------------------------------------------------------------------
Below is Don's attempt to restate the above.
(Please help me correct this.)
-----------------------------------
Reducing a word litteral always gives a pointer to THAT word
litteral, whether or not it's defined.
Repeated use of reduce on a word litteral keeps returning the
same result, which is not a pointer to the original string s, but
only a pointer to the litteral word, 's , which can be used by the
native, 'get , to bring back the original string value.
reduce 's ==> s reduce reduce 's ==> s
If the value of a word is wanted, use "get".
get 's ===> "some text"
Reduce applied to a BLOCK actually evaluates its contents and
repeated use of reduce on a block CAN penetrate through multiple
levels of reference.
Examples:
---------
s: "some text" ===> "some text"
type? s ===> string!
reduce 's ===> s
the returned s here is a reference to 's , not to s itself
note: type? (reduce 's) ===> word! ;(not a string )
( I presume here that a direct reference to a string )
( must itself be of type string! ****see below )
reduce reduce 's ===> s
repeated use continues to return only a reference to 's
print (reduce 's) ===> s
print just does another reduce, so this s also points to 's
##### Applying reduce to a block is different. #####
reduce ['s] ===> [s]
the [s] on the right is a reference to [s] , not [s] itself
similar to the above action on a word litteral,
and from: type? first (reduce ['s]) ===> word! ;****
I presume the s inside the [ ] is not a direct reference
BUT it is a DIRECT reference to the string,
as applying reduce again makes clear
reduce reduce ['s] ===> ["some text"]
So the action of reduce on a block is different than its
action on litteral words. And my presumption about the
type? of a reference agreeing with its target is wrong !!
Any help would be appreciated.
Don
------------------------------------------------------------------