Mailing List Archive: 49091 messages

## [REBOL] Re: R: Re: This is a strange thing

### From: joel:neely:fedex at: 2-Jul-2001 15:11

```
Hi, Romano

Romano Paolo Tenca wrote:
> What has confuse me, i think, is this:
>
> >> b: "foo"
> == "foo"
>
> >> a: [b]
> == [b]
>
> >> reduce a
> == ["foo"]
>
> >> reduce a/1
> == b
>
> >> get a/1
> == "foo"
>
> Can you explain to me the different behaviour of Reduce with
> "a" and "a/1"?
>

First, take a look at HELP for REDUCE

>> help reduce
USAGE:
REDUCE value

DESCRIPTION:
Evaluates an expression or block expressions and
returns the result.
REDUCE is a native value.

ARGUMENTS:
value -- (Type: any)

When you REDUCE a block you get back a block of results (the
results of evaluating all expressions within the argument
block).

That's why

>> b: "foo"    == "foo"
>> a: [b]      == [b]
>> reduce a    == ["foo"]

However, a path (as an expression!) evaluates to whatever is
at
that path.  Therefore, evaluating

>> reduce a/1    == b

provides you with what is identified by A/1, namely the word B.
In the same way, given

glorp: make object! [
x: 17
y: 42
z: does [print "hello"]
]

one can say

>> reduce glorp/x    == 17

To understand your last line, consider this:

>> a/1    == b

tells us that what is in the 1 position of A is the word B.
The definition of GET is

>> help get
USAGE:
GET word /any

DESCRIPTION:
Gets the value of a word.
GET is a native value.

ARGUMENTS:
word -- Word to get (Type: any-word)

REFINEMENTS:
/any -- Allows any type of value, even unset.

that is, GET retrieves the value of a word.  So this expression

>> get a/1    == "foo"

first evaluates A/1 to the word B, then applies GET to B, and
returns the result, which is B's associated value "foo".

HTH!

-jn-

--

It's turtles all the way down!
joel'dot'neely'at'fedex'dot'com
```