Hi,

your explanation looks natural, but I am not sure, how it copes
with:

Example illustrating, that the same value and equality of Words
doesn't mean the same Binding (totally unnatural for human
languages and for some programming languages too):

blk: copy [a]
a: 11
b: make object! [append blk 'a a: 11]
print [
    mold blk
    ":"
    mold reduce blk
]
print [
    "Do the first and the second element above have the same
Binding?"
    same? first blk second blk
]

moreover, the "human approach" is out of luck when trying to
"predict" the behaviour of:

f: func [level] [
    make object! [
        a: 2 * level
        probe b: either zero? level [
            f 1
        ] [
            none
        ]
        a: a + 1
    ]
]
probe f 0

Regards
    L

> Ladislav:
> > Rebol differs from human languages in some respects. One of
them can be
> found comparing Rebol Values vs. Human Values (see
> http://www.geocities.com/lmecir.geo/evaluation.txt). This may be
a surprise
> for both  experienced and inexperienced programmer, because that
fact is
> hidden in other programming languages to some extent. Another
difference can
> be found comparing the behaviour of Rebol (CQSB/DRP) functions
with the
> behaviour of their Pure CQSB counterparts (see
> http://www.geocities.com/lmecir.geo/contexts.txt). A set of the
differences
> can be found studying the behaviour of code - modifying
functions like
> Repeat, Make Object!, Use, Foreach, ... The latter difference
can be
> considered a bug, of course, but it is present in Rebol
nowadays.
>
> This is quoted from Ladislav's web page:
> <Quote>
> ; create a block Blk containing a word 'a
> blk: copy [a]
> a: 12
> ; now append another word to Blk
> b: make object! [append blk 'a a: 13]
> probe blk
> ; test if blk contains equal words
> equal? first blk second blk
> equal? get first blk get second blk
>
> What is the reason behind such a "mystery"? The answer is
simple:
>
> *Words have Bindings*
>
> and the first Word in Blk has a different Binding, than the
second.
> </Quote>
>
> I differ slightly in my interpretation.
>
> >> ; create a block Blk containing a word 'a
> >> blk: copy [a]
> == [a]
> >> a: 12
> == 12
> >> ; now append another word to Blk
> >> b: make object! [append blk 'a a: 13]
> >> probe blk
> [a a]
> == [a a]
> >> ; test if blk contains equal words
> >> equal? first blk second blk
> == true
> >> equal? get first blk get second blk
> == false
> >> first blk
> == a
> >> second blk
> == a
> >> get first blk
> == 12
> >> get second blk
> == 13
> >> a
> == 12
> >> b/a
> == 13
> >> probe a
> 12
> == 12
> >> probe b
>
> make object! [
>     a: 13
> ]
> >>
>
> Words have meanings (or values). The meaning of a word depends
on it's
> context. Two words may look the same, but can have different
meanings,
> because of their different contexts. 'b is an object with a
different
> context to the surrounding context. The word 'a inside 'b has a
different
> meaning from the 'a defined inside the global context. While the
two words:
>         first blk
>     and:
>         second blk
>     look the same, they both result in 'a, they have different
meanings. The
> first means:
>         12
>     and the second means:
>         13
>
> That's all there is to it. It's very like human language. For
example,
> "bear". There's a bear in the woods. That's all it can bear. Two
words
> exactly the same like [a a], but with different meanings. Here
the
> surrounding words supply the context, enabling the reader to
know that the
> first "bear" (a) means a four legged mammal (12), while the
second "bear"
> (a) means an amount of weight (13).
>
> One can change the meaning of the word by binding it into a
different
> context. Here I bind the block into the global context:
>
> >> bind blk 'a
> == [a a]
> >> get first blk
> == 12
> >> get second blk
> == 12
>
>     and so make both words in the block mean the same. I can
reassign the
> meaning of the words in the block by 'bind-ing the block's words
into the
> context of the object 'blk, like this:
>
> >> bind blk in b second first b
> == [a a]
> >> get first blk
> == 13
> >> get second blk
> == 13
>
> And I really like the simplicity of the line:
>         bind blk in b
>     which really means what it says. The only confusing thing
is:
>         second first b
>
> >> first b
> == [self a]
>
>     'first on a object gets you a list of words in the object.
While 'second
> simply gets the first word after 'self:
>
> >> second first b
> == a
>
>     so allowing the 'bind to work.
>
> >> help in
> USAGE:
>     IN object word
>
> DESCRIPTION:
>      Returns the word in the object's context.
>      IN is a native value.
>
> ARGUMENTS:
>      object -- (Type: object)
>      word -- (Type: word)
>
> Ladislav:
> > My personal point of view is, that my previous experience with
other
> programming languages helped me to understand Rebol and
appreciate its
> advantages.
>
> There's two succesful approaches to understanding Rebol. Have
little
> understanding of conventional computer languages - the innocent
approach.
> Have lots of understanding of conventional languages as Carl
Sassenrath has
> done and as most likely, Ladislav has. If you know one or a few
conventional
> third generation languages, then you're behind on the learning
Rebol curve,
> until you unlearn these languages.
>
> Andrew Martin
> See Rebol, Do Rebol, Know Rebol...
> ICQ: 26227169
> http://members.xoom.com/AndrewMartin/
> -><-
>
>

Reply via email to