[REBOL] Re: Puzzle with FIND and SELECT
From: joel:neely:fedex at: 10-Feb-2003 7:33
Hi, Romano,
Metaphysics, anyone? ;-)
Romano Paolo Tenca wrote:
> But i know that every rebol value is in a block at a given position.
> Beyond its attributes, it has a block position.
> Literal values, for example, have never the same block position:
>
> same? "a" "a"
> same? 1 1
>
> should result both false.
>
Which raises the following questions IMHO:
- Why? If "same" means "indistinguishable by any means (within
the language)" then aren't all occurrences of e.g. 1 the "same"?
- Why do we need SAME? at all? One use is to distinguish mutable
values so that one can determine in advance whether a change via
one "access path" will affect what is visible via another? That
said, are there others? Does this imply that immutable values
of the same type (see below) which are equal are indistinguishable?
- Do we need more state into the semantic model? Even if we accept
the notion that "every REBOL value is in a block...", some blocks
are inaccessible (e.g. blocks resulting from the load/eval/print
cycle at the console). This already means that we can't take any
arbitrary expression and wrap it in a function without the risk
of changing its semantics, as in the classic REBOL-newbie koan:
>> repeat i 10 [append [] i]
== [1 2 3 4 5 6 7 8 9 10]
>> foo: func [n [integer!]] [repeat i n [append [] i]]
>> foo 5
== [1 2 3 4 5]
>> foo 5
== [1 2 3 4 5 1 2 3 4 5]
- Are we cracking an egg with a sledgehammer? I started this thread
with a puzzle that cost me more time than I care to admit when it
came up in debugging a small script. In a nutshell, the issue was
>> foo: [1 2 3.0 4 5] == [1 2 3 4 5]
>> find foo 3 == none
>> equal? foo/3 3 == true
>> same? foo/3 3 == true
And my proposed solution is that a DECIMAL! value and an INTEGER!
value should never be SAME? (even if EQUAL!) because they *are*
distinguishable by some means in the language (TYPE? of each).
Since RT apparently has chosen TYPE? to be a discriminator for
FIND and SELECT it should be relevant to SAME? at least AFAIAC.
> So i think that same? gives the correct result only for mutable
> values.
>
All of these (my) comments are dangerous, being about what REBOL
should
do in the opinion of (at least one of) its users, and not
about what REBOL was intended to do in the opinion of its creator.
It would be nice to hear from Carl about the original intent
behind some of these things.
-jn-