[EMAIL PROTECTED] wrote:
> 
> ... I would probably interpret it as a funny compliment.
> 

Exactly.  Wheaties -- a brand of breakfast cereal that is advertised
as being very healthy -- has for many years featured photos of famous
athletes on the box.  Their advertising slogan, "He's been eating his
Wheaties!", became slang for, "He's really fit and full of energy!".

You appear to have been digging energetically in the REBOL basement
and uncovering all sorts of interesting things lately.

Sorry if I went overboard on the obscurity.

>
> What was I trying to underline was this:
> 
> f: func [] [print "Executed"]
> (((:f)))
> 
> with any number of parentheses yields the same result. Another example:
> 
> do [do [:f]]
> 
> you can use any number of blocks here too...
> 
> But, consider this:
> 
> do head insert copy [] do [:f]
> 
> >> do head insert copy [] do [:f]
> Executed
> 
> You get a different result, which looks slightly illogical to me.
> 

I think, however, that what's happening in your example has to do
with the behavior of parens, blocks, and 'do, rather than the
evaluation of functions.  The fact that 'f is bound to a function
may be distracting us, so let's try doing the same thing without
a function involved.

Consider:

    >> s: "Evaluated"
    == "Evaluated"
    >> s
    == "Evaluated"
    >> 's
    == s
    >> (((('s))))
    == s
    >> do [do [do ['s]]]
    == s
    >> head insert copy [] do ['s]
    == [s]
    >> do head insert copy [] do ['s]
    == "Evaluated"

Evaluating the lit-word 's produces the word s, and evaluating the
word s produces the string "Evaluated".  I think this is parallel
to saying that evaluating the get-word :f produces the function
above, and evaluating that function produces the (action of)
printing of the string "Executed".

Evaluating a paren causes evaluation of its content, so that

    >> (((('s))))
    == s

occurs for any number of levels of parentheses.  "Wrapping" an
expression in a block inhibits its evaluation, so that

    >> ['s]
    == ['s]
    >> [['s]]
    == [['s]]
    >> [[['s]]]
    == [[['s]]]

and so on.  However 'do seems to operate on a block by "unwrapping"
one level of block nesting and evaluating whatever is there.

    >> do [[['s]]]
    == [['s]]
    >> do [['s]]
    == ['s]
    >> do ['s]
    == s

Multiple 'do's can be chained to unwrap multiple levels.

    >> do do do [[['s]]]
    == s

Now let's apply all this to your last example, which seemed to be
doing something different.

    >> do head insert copy [] do ['s]
    == "Evaluated"
    >> s
    == "Evaluated"

where we see that the complicated expression on the first line seems
to produce the same effect as evaluating the word standing alone.
Looking at this one step at a time:

    >> do probe head probe insert copy [] probe do ['s]
    s
    []
    [s]
    == "Evaluated"

the first intermediate value matches our expectations from the above
investigations of 'do and block nesting

    >> do ['s]
    == s

giving us back the word s (by evaluating the lit-word 's).

That word is then "rewrapped" in a block by the 'insert expression,
whose VALUE is a block at the position after the inserted data.

    >> insert copy [] do ['s]
    == []

but whose SIDE-EFFECT is to modify the (originally empty) sequence,
which we can recover with 'head

    >> head insert copy [] do ['s]
    == [s]

So, finally, we're left with the word s "wrapped" in a block, which
we can "unwrap" and evaluate with 'do.

    >> do [s]
    == "Evaluated"

Therefore, I conclude that we can place

    "do head insert copy [] do ['"

in front of (a string that is the name of) a word, follow it with

    "]"

and end up with (a string that represents) an expression that will
evaluate to the same thing as evaluating the word itself.

    >> complicated-wrapper: func [w [string!]] [
    [    join copy "do head insert copy [] do ['" [w "]"]
    [    ]
    >> complicated-wrapper "s"
    == "do head insert copy [] do ['s]"
    >> do complicated-wrapper "s"
    == "Evaluated"

    >> f: func [] [print "Executed"]
    >> f
    Executed
    >> complicated-wrapper "f"
    == "do head insert copy [] do ['f]"
    >> do complicated-wrapper "f"
    Executed

    >> testcase: to-paren [2 + 2]
    == (2 + 2)
    >> testcase
    == 4
    >> complicated-wrapper "testcase"
    == "do head insert copy [] do ['testcase]"
    >> do complicated-wrapper "testcase"
    == 4

FINALLY (whew!) this implies to me that all of the above is simply
an exploration of parens, blocks, and 'do.  THEREFORE, your model
for evaluation may still be valid -- and I'd be very interested to
hear about it!

-jn-

Reply via email to