[EMAIL PROTECTED] wrote:

> Ahoj, Petre, hezke vanoce (Hi, Peter, Merry Christmas)

Ooo, diky, totez preju Tobe :-)

> can't resist to show you a few examples of Rebol code (just for fun, don't
> be afraid).
>
> Ex1:
>
> f: func [/local a][
>     do func [] [
>         a: ""
>     ]
>     insert a "1"
> ]
>
> Results:
> >> f
> == ""
> >> f
> == ""
>
> interesting, isn't it?
>

hmm, yes, I would expect so, as new function seems to introduce separate
context, or am I mistaken? It seems to me like some kind of object orientation,
e.g. in language we are using here, we have Export, Protect and Hidden variables
available to Classes. In your example above, 'a reminds me of Protect variable,
visible in subclasses too. The problem is, 'a was initialised inside of
underlying function, so remembering me of Export type variable :-)

> Ex2:
> a: [""]
> b: copy a
> change/only a "x"
> a
> b
>
> >> a: [""]
> == [""]
> >> b: copy a
> == [""]
> >> change/only a "x"
> == []
> >> a
> == ["x"]
> >> b
> == [""]
> You see, that by changing A we didn't change it's copy B.
>
> Ex3:
> a: [""]
> b: copy a
> insert first a "x"
> a
> b
>
> Results:
> >> a: [""]
> == [""]
> >> b: copy a
> == [""]
> >> insert first a "x"
> == ""
> >> a
> == ["x"]
> >> b
> == ["x"]
>
> Now, even B looks changed. How did I manage to do it?

What a mess :-)

-pekr-

>
>
> Ladislav
>
> [EMAIL PROTECTED] wrote:
>
> > Let's consider now another version of the Mystery Function that has
> > been discussed in this thread.
> >
> >     >> container: ["" "x"]
> >     == ["" "x"]
>
> >
> > This word just holds a block of data.  The first element of the block
> > is a reference to an empty string; the second element is a reference
> > to a string of length 1.
> >
>
> Exuse me folks - I am far from being expert in language theories or
> programming,
> so I will represent "simple" view here.
>
> I know we all try to find best way to describe the behavior, but I wonder in
> following:
>
> 1) use language features to describe it's components:
>
> - there is no 'reference nor 'reference? function, so?
> - type? first container returns string!, so it is string and from that point
> of
> view should not be regarded anything else, dot.
> - value? first container returns true, so the empty string itself has a
> value
> - >> source value?
> value?: native [
>     "Returns TRUE if the word has been set."
>     value
> ]
> hmm, "... if the word has been set." What word are we talking about here?
> The
> description for 'value? shoul be changed then.
>
> So, as for Rebol itself, it fails to describe what "" and [] really are.
>
> 2) I've thought REBOL is about simplicity, not confusion. If there is a
> problem
> because of "" [] only, remove the problem!
> What about one exception in REBOL - always create copy of "" [] by default
> ...
> Wouldn't it help to remove all unintuitiveness we are talking about here?
> Look
> also at following:
>
> ->> container: ["" "x" ""]
> == ["" "x" ""]
> ->> source same?
> same?: native [
>     "Returns TRUE if the values are identical."
>     value1
>     value2
> ]
> ->> same? first container third container
> == false
>
> or
>
> ->> a: ""
> == ""
> ->> b: ""
> == ""
> ->> insert a "Ahoy"
> == ""
> ->> print a
> Ahoy
> ->> print b
>
> ->> print head b
>
> So, from another point of view ""s reference to some empty strings, but not
> the
> same ones! If so, how's that 'a, used as a local in a function, initialised
> to ""
> in the body of function, refers to the same string?
>
> example: func [/local a][a: "" insert a "1" print a]
>
> In above example, 'a and 'b refer to empty strings, the different ones. So,
> if 'a
> is local in our function, each function call should refer to DIFFERENT ""
> string.
> Or indefinite extent in action here? I think not.
>
> >From the Amiga land, I remember one motto: KISS - keep is simple, stupid.
> And
> simple means - the thing works the way most people expect it to work. Can we
> afford such exceptions in the language? What about introduction of  new
> datatypes?
> any-string, empty-string ... Could it help?
>
> 3) I just wonder, why are REBOL Tech. folks so silent? Why not enter the
> discussion, introducing proper solution? I would expect it from language
> creators.
>
> As for me, I can live with a: copy "" or a: make string! "", but care should
> be
> taken of REBOL newcomers ...
>
> Regards,
>
> -pekr-
>
> >
> > -jn-

Reply via email to