Type | Wish | Status | problem | Date | 18-Jun-2014 11:09 |
---|---|---|---|---|---|
Version | r3 master | Category | Datatype | Submitted by | fork |
Platform | All | Severity | minor | Priority | normal |
Summary | Allow single-character strings to compare equal to the single character |
---|---|
Description |
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. |
Example code |
Assigned to | n/a | Fixed in | - | Last Update | 22-Jun-2014 02:48 |
---|
Comments | |
---|---|
(0004461)
BrianH 22-Jun-2014 02:47 |
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. |
Date | User | Field | Action | Change |
---|---|---|---|---|
22-Jun-2014 02:48 | BrianH | Description | Modified | - |
22-Jun-2014 02:48 | BrianH | Category | Modified | Unspecified => Datatype |
22-Jun-2014 02:48 | BrianH | Status | Modified | submitted => problem |
22-Jun-2014 02:47 | BrianH | Comment : 0004461 | Added | - |
18-Jun-2014 11:09 | Fork | Ticket | Added | - |