Wow!  I'm amazed that anyone would have the time and patience to wade
through the whole thing (not to mention coming up with such useful
feedback) so quickly!

Let me make a couple of "blanket" observations before addressing the
individual points you raised.

BREVITY:
I was very concerned that letting the essay continue to grow in length
would interfere with its readability.  Therefore, I deliberately tried
to include just enough detail to present the key ideas of the model.
I'm quite happy to continue editing/expanding from this first draft,
which is a kind of "beta" version intended to see whether it's worth
continuing the effort.

FOCUS:
I left out any real details on getting and setting, partly because of
the BREVITY goal above, and partly due to my own current limits.  I
have a very clear model in my head for multiple "environments" by
which the same "variable" can be associated with different values,
but it is based on my prior experience with LISP, Scheme, and other
languages.  Since I haven't had the time yet to stress-test it as a
reasonable model for the REBOL context, I tried to avoid saying too
much about it (yet).

Now, on to your specific comments:

[EMAIL PROTECTED] wrote:
> 
> Hello Joel,
> 
  ...
> 
> 1. We need to stress the uniqueness of series values more.
> 
> >From essay/2
> 
  ...
> >
> >    {{block! 1 *}}
> >               |
> >               V
> >               <<10 * 12>>
> >                    |
> >                    V
> >                    {{string! 1 *}}
> >                                |
> >                                V
> >                                <<#"1" #"2" #"3" #"4">>
> 
> You say that asterisks plus arrows denote references. I wonder if it
> might not be more accurate to say:
> 
>     {{block! 1 *}}
>                |
>                V
>                <<10 {{string! 1 *}} 12>>
>                                 |
>                                 V
>                                 <<#"1" #"2" #"3" #"4">>
> 
> At least in my mental picture of blocks, series values are directly
> embedded within blocks, rather than being referenced.

I'd have to think about whether that abbreviation makes any difference
at the REBOL source level.  However, I had two reasons for drawing it
the way I did.

1)  I wanted to emphasize subtly the fact that when one has a
(reference to a) series, it doesn't matter whether it came from a
variable, another block containing that series, or is an
intermediate (and therefore temporary) value which only exists
during expression evaluation, the series behaves the same.

2)  My experience suggests to me that there are all kinds of reasons
(simplicity of memory management being an important one) why one
would want to build a composite data structure only once and create
multiple references to it.  This gets into speculation about the
actual code in the REBOL interpreter that I'd prefer to keep separate
from the essay. 

> That might well be inaccurate
> somewhere within the implementation level, but on the model level
> I think your picture may be confusing. For example, in your next
> diagram:
> 
> >    a -> {{string! 1 *}}
> >         ^           |
> >         |           V
> >    b ---+           <<#"1" #"2" #"3" #"4">>
> 
> I think there's an error. 'a and 'b are bound to different (but identical)
> series values, although the underlying sequence is of course the same. I
> think it would be better to represent this situation as:
> 
>     a -> {{string! 1 *}}
>                      |
>                      V
>                      <<#"1" #"2" #"3" #"4">>
>                      ^
>                      |
>     b -> {{string! 1 *}}
> 

I think that these two pictures are actually totally equivalent in
describing behavior at the REBOL source level.  Consider:

    >> a: "1234"
    == "1234"
    >> b: a
    == "1234"
    >> same? a b
    == true

It's easy for me to understand this as 'a and 'b referring to exactly
the same entity in memory, but after

    >> b: next a
    == "234"
    >> same? a b
    == false
    >> c: head b
    == "1234"

it's more plausible to me that 'c refers to an entity that is totally
equivalent to the one referred to by 'a, rather than to imagine that
the interpreter searched through memory to find out whether such an
entity already existed.

    >> same? a c
    == true

However, at this point I believe that they are indistinguisable, in
the sense that any expression involving (NOT setting) a's value
could have been evaluated using c's value with equivalent results.
(I'm dancing through a mine field with the above wording.  If it
needs more discussion, let's address it separately.)

> This revised diagram is very similar to one in essay/3:
> 
> >    a -> {{string! 1 *}}
> >                     |
> >                     V
> >                     <<#"1" #"2" #"3" #"4">>
> >                     ^
> >                     |
> >    b -> {{string! 2 *}}
> 

Yes, but in that case the indexes are different, therefore the
model says that there ARE two distinct series entities.

> Also, in essay/4 you have:
> 
   ...
> >    a ---> {{string! 1 *}}
> >                       |
> >                       V
> >                       <<#"1" #"2" #"3" #"4">>
> >                       ^
> >                      / \
> >                     /   \
> >    b -> {{string! 2 *}}  \
> >                           \
> >    r -------> {{string! 1 *}}
> 
> which I wouldn't quarrel with. Just as I've said before, the value
> of 'r is a different but identical instance of the value of 'a.
> 

Yes.  As above, I think that references to "different but identical"
string entities (same sequence, same index) are indistinguishable
at the REBOL source level from references to the same entity.  I
just didn't want to risk making the reader worry about whether the
interpreter somehow searched all words in scope looking for an
equivalent reference, instead of just creating the series entity.

>
> (I assume you meant to represent the sequence as
> <<#"1" #"2" #"3" #"4" #"X">>)
> 

YES!  You have a sharp eye!  I drew those diagrams at least three
times, trying to make the ASCII art as un-ugly as I could, and
obviously let this error slip through.  I'll correct and repost.

>
> To flog this idea a little more, what would you do with a simple case of
> integers:
> 
> a: 5
> b: a
> 
> ? Does this give you:
> 
>      a -> 5
>           ^
>           |
>      b ---+
> 
> or:
> 
>      a -> 5
>      b -> 5
> 
> ? Obviously the latter picture is more accurate, since there's nothing
> you can do to 'b now to change the value that 'a is bound to. Further
> there is no way you can ask 'a or 'b whether there is another word bound
> to the same value.
>

I agree with everything except the conclusion.  ;-)  Seriously, we agree
that no operation involving 'b can affect future evaluations of 'a.
Actually, I think one COULD write code which would find any other
currently
defined words which evaluate to the same value as a given word (consider
'what), but I think we'd agree that doing so would be of limited value
(pardon the pun! ;-)

What we're really dealing with is the fact that any two instances of 5
are
TOTALLY interchangeable; therefore, I'd just say that your two pictures
above
are equivalent, without worrying about which one the intepreter
currently
actually implements.

> 
> So, in the same way, after:
> 
> a: "1234"
> b: a
> 
> the only way to change the value 'a is bound to is by changing the
> underlying sequence - you cannot change the basic information in the
> value of 'a - neither __which__ sequence is referenced, nor the index.
>

We're agreed on that.

>
> Your diagrams seem to leave that possibility open.
>

Hmmm.  I wasn't trying to imply that, but I can see how it could be read
that way.  What I WAS trying to emphasize is that one can only modify
a sequence value via a series referring to it, but that ANY series that
refers to it can be used.

> 
> NOTE: Please see my PS on lists.
> 
> 2. We should graphically show the difference between binding and reference.
> 
> As I understand it, the relationship between words and the values they are
> bound to, and the relationship between series values and the sequences they
> refer to are entirely different. One really should use a different form of
> arrow for these two, although that would be difficult with the ASCII lower
> 128!
> 

I just didn't want to make an issue of that distinction (see FOCUS,
above).
I'd like to confirm my suspicions about context behavior before I intro-
duce that, and I'd like to keep it a separate issue if possible.

Can you think of any examples of REBOL expressions where having a word
refer to a series produces different behavior than having a series
element
refer to the same series?

>
> 3. Sequences are typed, too.
> 

Since the only way REBOL code can "get at" the sequence is via a
series, I assume that type checking is done via the/any series
reference before we get down to the sequence.

>
> Your diagrams seem to leave open the possibility of this kind of
> situation:
> 
>     a -> {{string! 1 *}}
>                      |
>                      V
>                      <<#"1" #"2" #"3" #"4">>
>                      ^
>                      |
>     b --> {{email! 1 *}}
> 
> which is of course impossible.
>

But "impossible" means that there's no REBOL expression whose
evaluation would lead to that condition (as far as I know).  I
can draw lots of pictures that don't correspond to anything that
REBOL does, including:

    a -> {{string! 1 *}}
         ^           |
         |           |
         +-----------+

which is meaningless as a description of REBOL data.  Since I was
trying to come up with diagrams for a model that precisely
describes concepts that REBOL documentation glosses over, I felt
that I needed more expressive power/detail.  Unfortunately, I
don't know how to keep that power from being mis-used, except to
say, "But REBOL doesn't do that." as needed.  I'm open to
suggestion, but don't want to burden this informal notation with
more syntax rules than absolutely necessary.

> Perhaps:
> 
>     a -> {{* 1}}
>            |
>            V
>            <<string! | #"1" #"2" #"3" #"4">>
> 
> would be better.
> 

I suppose it comes down to a judgement call.  I just tend to think
of the expressions

    type? a
    index? a

as asking for information about the series itself.  I also suspect
that they are quicker to evaluate if one has to follow fewer
levels of references.

>
> 4. Couldn't indexes be portrayed graphically?
> 
   ...
> 
> For example, one of the diagrams quoted above could be represented as:
> 
>            a -> {{* 1}}
>                   |
>                   V
>       <<string! | #"1" #"2" #"3" #"4">>
>                        ^
>                        |
>                 b -> {{* 2}}
> 
> This has the advantage of showing us immediately where INSERT will operate.
> So if we do:
> 
>       insert a "XYZ"
> 
> we get:
> 
>            a -> {{* 1}}
>                   |
>                   V
>       <<string! | #"X" #"Y" #"Z" #"1" #"2" #"3" #"4">>
>                        ^
>                        |
>                 b -> {{* 2}}
> 
> I'm sure you must have considered this possibility and rejected it...
> 

Were you looking over my shoulder the other night???  Actually, I
did try that in an earlier (unpublished) version of the essay, but
gave it up for the following reasons:

1)  I was concerned that it would make explanation of 'insert MORE
confusing.  Some folks seem initially surprised that after

    a: "1234"
    b: next a
    insert a "XYZ"
    print first b

the console displays Y instead of 2.  I wanted to emphasize that
'b refers to "that thing over there, beginning with position 2"
rather than to the #"2" itself.

2)  As you point out in your later remarks on lists, that case
can probably be understood better as a direct reference involving
the element itself.  I wanted to hold that issue in reserve for
the moment.

> 
> PS I'm starting to enjoy playing around with your diagrams! Let me see what
> I can do with one from essay/5:
> 
> >    a: "1234"
> >    x: [a: "987"]
> [snip]
> >    do x
> >
> >the situation is different (and fairly distinctive to REBOL):
> >
> >    a -------------------------+
> >                               |
> >                               |
> >    x -> {{block! 1 *}}        |
> >                    |          /
> >                    V         /
> >                    <<a: *>> /
> >                          \ /
> >                           V
> >                           {{string! 1 *}}
> >                                       |
> >                                       V
> >                                       <<#"9" #"8" #"7">>
> 
> This is what I'd like to do (with a double-lined arrow for binding):
> 
>     a ===============================> {{* 1}}
>                                          |
>     x ------------------> {{* 1}}        |
>                             |            |
>                             V            |
>                  <<block! | a: {{* 1}}>> |
>                                   \      |
>                                    \     |
>                                     \    |
>                                      \   |
>                                       \  |
>                                        \ |
>                                         \|
>                                          V
>                              <<string! | #"9" #"8" #"7">>
> 
>

Not to get too far into it, but I think of binding in terms of HOW
we take a word and get (a reference to) its value, not something
that is distinctive about the reference itself.

>
> Actually, I'm still leaving something out, which can be demonstrated as
> follows:
> 
> >> x: [a: "987"]
> == [a: "987"]
> >> do x
> == "987"
> >> get x/1
> == "987"
> >> x/1
> == a:
> 
> The set-word a: has the same binding as the word a, so we really should
> also draw =====> from the first element of the sequence
> <<block! | a: {{* 1}}>> to the value {{* 1}} in the upper right corner.
> (In this case a and a: really are bound to the same instance of the
> series value.)
> 

Privately, I think of the set-word as a distinct entity which refers
to its own word (something similar to the diagram below) but until I can
experiment a bit more (or the REBOL gurus give us a peek into the magic
cave!) I want to hold off committing too far.  And, again, I wanted to
keep the focus on the series model in the first draft.  These are all
very interesting questions, though, and I'd like to have some more
discussion on them.

              ( binding )
    a --------(  magic  )----------+
    ^         ( happens )          |
    |                              |
    |   x -> {{block! 1 *}}        |
    |                   |         /
    |                   V        /
    |                   <<* *>> /
    |                    /   \ /
    |                   /     V
    |                  V      {{string! 1 *}}
    |    {{set-word! *}}                  |
    |               /                     V
    L______________/                      <<#"9" #"8" #"7">>

>
> Let me do just one more!
> 
> In your diagram in essay/6 following:
> 
> a: [1 "st" 2 "nd"]
> b: a
> c: copy a
> append b [3 "rd"]
> insert a/2 a/1
> insert a/4 a/3
> 
> you forgot to show the effects of the two inserts...
>

Another "I've-done-this-several-times-already-so-hurry-up-and-post-it"
error.  Thanks for finding it!

> PS on lists (as promised):
> 
 ...
> 
> A list value doesn't include a numerical index; it includes a
> "direct" reference to an element in the list sequence, so that the
> numerical index of a list value may change.

That may be the best case for letting list references point INTO the
sequence, while block references refer to the entire sequence...
Maybe?

> There are further surprises:
> 
 ...
> 
> The element referenced through the value of 'a disappeared, so
> apparently 'a only references the list sequence, and has no valid
> index value.
> 

Clearly, I'd like to understand lists better before I commit to
a notation with too many possible implications.

THANKS FOR YOUR COMMENTS!

-jn-

Reply via email to