[REBOL] Re: to-path newline problem?
From: joel:neely:fedex at: 14-Aug-2001 2:02
Hi, Ladislav,
Thanks for the examples!
Ladislav Mecir wrote:
> >
> > really-and-truly-equal: func [:x :y] [
> > to-logic all [
> > equal? x y
> > equal? mold x mold y
> > ]
> > ]
> >
> > >> really-and-truly-equal :bp :ubp
> > == false
> >
> > ... and, of course, test with all possible datatypes as
> > arguments (and equality tests over all possible generic
> > transformations) to make sure we don't need another phrase
> > in the ALL block! ;-)
> >
>
> Some comments:
>
> words behave the same way:
>
> alias 'a "aa"
> equal? 'a 'aa ; == true
> equal? mold 'a mold 'aa ; == false
>
Fortunately this one requires no new test ;-)
>> really-and-truly-equal 'a 'aa
== false
> another example:
>
> equal? "a" "A" ; == true
> equal? first "a" first "A" ; == false
>
>> equal? "YouAreNowhere" "YouAreNowHere"
== true
Ah, yes! The old IBM-mainframe-3270-and-80-column-punch-card
concept of "Shift key? We don't need no stinkin' shift key!"
still perpetuated in Visual CP/M 2000.
How silly (or Freudian) of me to forget this "feature"!
really-and-truly-equal: func [:x :y /local same-chars?] [
same-chars?: func [ls [string!] rs [string!]] [
forever [
if all [empty? ls empty? rs] [return
true]
if (first ls) <> first rs [return
false]
ls: next
ls
rs: next
rs
]
]
to-logic all [
equal? x y
equal? mold x mold y
same-chars? mold x mold y
]
]
... thus your new examples ...
>> really-and-truly-equal "YouAreNowhere" "YouAreNowHere"
== false
>> really-and-truly-equal 'a 'aa
== false
... and the original ...
>> b: [
[ hellow
[ therex
[ ]
== [
hellow
therex
]
>> bp: to-path b
==
hellow/
therex
>> ubp: to-path foreach w b [append [] to-word w]
== hellow/therex
>> equal? :bp :ubp
== true
>> really-and-truly-equal :bp :ubp
== false
Any others?
Seriously, at least the case-ignorant behavior of string
equality testing is documented, and the use of ALIAS is
sufficiently uncommon that one might be cautious about
making too many assumptions. However, the insistence on
retaining the locations of line breaks in the original
expression is really a puzzler, especially in view of the
difficulty of getting rid of (some of) them.
>> b
== [
hellow
therex
]
>> copy b
== [
hellow
therex]
>> copy/deep b
== [
hellow
therex]
>> foreach w b [append [] w]
== [
hellow
therex]
>> compose [(b)]
== [
hellow
therex]
>> foreach w b [append [] to-word w]
== [hellow therex]
This "feature" really cries out for some form of official
documentation IMHO.
-jn-
--
------------------------------------------------------------
Line breaks: sneaky, obscure, mysterious ...
Pick any two!
joel'dot'neely'at'fedex'dot'com