metaeducation / rebol-issues

6 stars 1 forks source link

Allow single-character strings to compare equal to the single character #2158

Open rebolbot opened 10 years ago

rebolbot commented 10 years ago

Submitted by: fork

Rebol has to have a unique type for a character to participate as an element of a string.

But just as people have repeatedly and stalwartly defended the default equality operator comparing 1.0 and 1 to be equal:

>> 1.0 = 1
== true

I'll suggest it would be highly beneficial to allow single-character strings and characters to compare as equal in the default equality operator:

>> "a" = #"a"
== true

This would not make the types compatible or interchangeable in other senses besides comparison, and stricter equality operators that would report 1.0 as not being equal to 1 due to being different value types would also report them as unequal.

CC - Data [ Version: r3 master Type: Wish Platform: All Category: Datatype Reproduce: Always Fixed-in:none ]

rebolbot commented 10 years ago

Submitted by: BrianH

See #1834 for the general reshuffling of the equivalences, of which this would need to be a part if we do this.

Overall, this seems problematic to me. This isn't just a matter of datatypes: a character and a string are categorically different, and the operations that apply to them are very different, so they're generally not interchangeable in regular code. A character has more in common with a number than it does with a string, regardless of how they look. You can't do math operations on a string, you can't get the value at a position of a character, and incrementing means something completely different for each, for instance. This seems like it would cause more problems than it would be worth.