[EMAIL PROTECTED] wrote:
> 
> Hi Joel,
> 
> I think there's a big problem when the docs use a vague term like
> "convert to a string," since there are several ways that values
> may be converted to strings.
> 

You're absolutely correct, IMHO!

One of the things we need the docs to do is explain WHY there are
so many ways and when (as your examples below so well point out)
each is used.  The distinction between  form  and  mold  IS
addressed in the docs (and -- fortunately! -- none of the confusing
cases seem to have  mold  as part of the picture).

I don't think I've mentioned this analogy before on the list, but
some aspects of REBOL (such as discussed in the "series" thread of
several months back) make me feel as if I'm doing nuclear physics
while trying to learn, use, and explain REBOL.  I take it on faith
that there are some interesting particles in there, but I have no
way to perceive them with the naked eye, nor have I had a spec that
told me what they were doing.  So, it became necessary to draw on
my experience with other languages to imagine what they MIGHT be
doing, and then to think up experiments that probe those hypotheses
and confirm or refute them.

It is possible (and even fun!) to learn things that way -- I once
figured out the six-stack microcoded implementation of an
Algol-like systems programming language by trying things out and
reading core dumps -- but it certainly isn't the most efficient
nor the easiest on the nerves!

-jn-

>
> As Andrew Martin noted, the cause of the strange behavior seen by JOIN is
> INSERT's behavior (also seen with APPEND).
> 
> It seems that INSERT uses FORM to convert values contained in blocks before
> inserting them, and TO STRING! to convert values which aren't contained in
> blocks. Most of the time the results of TO STRING! and FORM are the same, but
> there are several differences.
> 
> >> to+form: func[v][print to string! :v print form :v]
> >> to+form pi
> 3.14159265358979
> 3.14159265358979
> >> to+form %file.ext
> file.ext
> file.ext
> >> to+form to binary! "binary"
> binary
> #{62696E617279}
> >> to+form first [abc/def/ghi]
> abcdefghi
> abc/def/ghi
> >> to+form ["abc" "def" "ghi"]
> abcdefghi
> abc def ghi
> 
> These differences correspond exactly to the behavior of INSERT, APPEND and
> JOIN:
> 
> >> append "" to binary! "binary"
> == "binary"
> >> append "" reduce [to binary! "binary"]
> == "#{62696E617279}"
> >> append "" first [abc/def/ghi]
> == "abcdefghi"
> >> append "" [abc/def/ghi]
> == "abc/def/ghi"
> >> append ""  ["abc" "def" "ghi"]
> == "abcdefghi"
> >> append ""  [["abc" "def" "ghi"]]
> == "abc def ghi"
> 
> Eric
>

Reply via email to