[EMAIL PROTECTED] wrote:
> 
> Hi Elan,
> 
> (I think Joel may have used the phrase "the empty string" as a
> concept rather than meaning "the unique empty string in the
> example".)
>

That's a completely reasonable interpretation of what I wrote.  I
actually meant to say "an empty string", which is pretty much what
you seem to have understood.

> 
  ...
> 
> >>> same? "" ""
> >== false
> 
> In this latter illustration both literal strings are independent
> entities, because REBOL creates both of them when it parses the
> string {same? "" ""} typed in at the console. That still is no
> guarantee that all "literal strings" are mutually independent
> entities.
> 
> What about this case:
> 
> >> a: [""]
> == [""]
> >> insert a first a
> == [""]
> >> a
> == ["" ""]
> >> same? first a second a
> == true
> 

You can get the same sort of phenomenon in a variety of ways.  For
example:

    >> a: ["" ""]
    == ["" ""]
    >> a/2: a/1
    == ["" ""]
    >> same? first a second a
    == true
    >> insert first a "Yep!"
    == ""
    >> b: reduce [a/1 a/1]
    == ["Yep!" "Yep!"]

>
> The block referenced by (bound to) 'a now contains two string
> values, both of which reference the same empty string.
> 
> This is one of the major points that Joel was trying to make in
> his series essay, and one that deserves careful attention. Even
> series values that look literal (that are not directly bound to
> a word) have a relationship of reference to the underlying data
> which they represent.
> 

Yes.  Only, I'd actually go further and claim that the whole
notion of "literal" is getting way too much attention here.  In
both of our examples, variable a was initialized with a "literal"
block containing one or more "literal" strings.  However, the
block just contains strings, not "literal strings"!  How they
were initialized places no constraints on how they may be
manipulated later on.

> 
> In conclusion, here's a puzzle, easily solved: how did I make this function?
> 
> >> source f
> f: func [x /local a b][a: "" b: copy "" append a x print b]
> >> f "I'm a geek"
> 
> >> f ", not!"
> I'm a geek
> >> f " OK?"
> I'm a geek, not!
> 

Cool!  The easiest way I can think of is something like this:

    >> f: func [x /local a b] [a: "" b: copy "NOT!" append a x print b]
    >> replace second :f "NOT!" second second :f
    == [a: "" b: copy "" append a x print b]
    >> f "I'm a geek"
    
    >> f ", not!"
    I'm a geek
    >> f " OK?"
    I'm a geek, not!

Thanks for the puzzle!  It illustrates VERY nicely what I was
attempting to say.

-jn-

Reply via email to