-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AnnotatedString equality contradicts docs #55244
Comments
In your example Initially, I didn't have annotations matter when comparing an |
Not sure how annotations affect code points (docs: "Unicode code point by code point").
Sure! I expected |
They don't, but the reasoning I put forwards is predicated on a character with annotations not being equal to a character without annotations.
We could do this, but I'd expect this behavior to be potentially surprising. I think the situation can be summed up like so: Current behaviorA string without annotations is equal to an unannotated string. Annotated strings are equal when the underlying string is equal, as are annotations. Option 1Loosen the "technically" to something like "often" in the Option 2Ignore annotations entirely when comparing |
Option 3Just document
|
Ah yep, though maybe that would need to explicitly mention ==(a::AnnotatedString, b::AnnotatedString)
==(a::AbstractString, b::AnnotatedString)
==(a::AnnotatedString, b::AbstractString) |
Yeah the current situtation is definitely weird: julia> a = Base.AnnotatedString("abc", [(2:3, :x => 123)])
"abc"
julia> a[1] == 'a' && a[2] == 'b' && a[3] == 'c'
true
julia> a == "abc"
false |
Ahh, I think that the |
Option 4Don't make This way |
Half the point of |
The issue is that as a Julia user, I have no idea which functions that use And define a fall back: |
Mmmm, I think there's an argument to be made for abandoning the inclusion of annotations in the concept of string equality, and require them to be checked separately if you do care. I'm not sure if this is the path we should take, but that is the alternative to the current situation. |
Judging by the AbstractChar / AbstractString docs, there are only two choices to keep everything consistent:
|
This issue remains in the actual release. Still, as I understand all this Annotated/Styled Strings/Chars stuff is officially considered experimental, and any future fixes won't be breaking. |
Indeed, this still needs to be worked out, but we've added the "Experimental!" note to give ourselves the space to do so. |
Docs:
Actual behavior:
Either the docs or the implementation are clearly wrong...
The text was updated successfully, but these errors were encountered: