-
-
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
RFC: Deprecate Int-Char comparisons, e.g. 'x' == 120 #16024
Conversation
What's going on the CI here? |
I don't think the PR CI will run with merge conflict (since it runs on merge commit) |
@@ -51,7 +51,9 @@ function parseinline(stream::IO, md::MD, config::Config) | |||
content = [] | |||
buffer = IOBuffer() | |||
while !eof(stream) | |||
char = peek(stream) | |||
# FIXME: this is broken if we're looking for non-ASCII |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woudn't peekchar
fix this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need peek
to match the current read
interface:
read(io, UInt8)
read(io, Char)
peek(io, UInt8)
peek(io, Char)
with the defaults matching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, peekchar
only works for the IOStream
type, so this fails.
I have to say that I'm not convinced that this change is a good idea. Comparison of |
@stevengj Is not |
@H-225, that's not the problem. You can already write |
@stevengj My bad - totally should have noticed that. |
Adding a new prefix system just to avoid typing a few chars? That doesn't sound worth it. |
Put it another way: has this change (a) caught any errors or (b) made the Base code cleaner? Looks like "no" on both counts? |
I think these are the important points here:
I therefore agree with @stevengj; we should not remove |
@H-225 These two examples don't make sense. They should be |
@nalimilan, the point is that there are lots of cases (e.g. see this PR!) where you have already read in a byte as a @H-225, it would seem rather odd and arbitrary if you could compare |
@stevengj: there are actually several places where there were actual or potential bugs here due to comparing That was also not the motivation for this change. Currently we have |
434a745
to
ed29d76
Compare
@StefanKarpinski, I don't see how having Making |
Because it decodes a Char value in whatever way is appropriate for the stream. Currently we don't support streams with different encodings, but that's something we should support in the future. For now it at least fixes the common problem for UTF-8 streams. |
ed29d76
to
496ebd3
Compare
|
@stevengj: I'm ok with making |
Because comparison of chars to integers is well-defined (Unicode), convenient, and a long-standing convention in many languages? They aren't really "incomparable types". |
So it's ok to compare |
The recent issue about comparing |
f3abb9e
to
3de874e
Compare
@StefanKarpinski, having @ararslan, the mapping of |
@ararslan, defining |
3de874e
to
013457b
Compare
while reviewing/fixup tests, I found one that asserts Line 3 in e0e93fc
|
If we're going to go down the road of having NotComparableError, then we should really go all in. I'm all for it, but I don't think it belongs in this fairly minimal PR to make |
@@ -478,6 +478,6 @@ precompile(Base.launch, (Base.LocalManager, Dict, Array{Base.WorkerConfig, 1}, B | |||
precompile(Base.set_valid_processes, (Array{Int, 1}, )) | |||
|
|||
# Speed up repl help | |||
sprint(Markdown.term, @doc mean) | |||
# sprint(Markdown.term, @doc mean) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what was wrong here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good catch. I commented it out because bootstrap was failing and then forgot to try putting it back in.
013457b
to
a248e1d
Compare
a248e1d
to
84349f2
Compare
Any idea why we're not getting AppVeyor CI on this? |
Nevermind, it kicked in after a while. |
Needs a NEWS.md item. |
My understanding is that once things are deprecated, they'll be removed in a future release. So if char-int comparison is deprecated, what are we envisioning the eventual behavior to be once it's removed entirely? A |
Saying that deprecation implies removal is a bit too narrow. Sometimes we need to change a behavior, e.g. changing a |
@JeffBezanson That's good to know, thanks! So the eventual behavior here is that |
It's also possible that it will be an error. Either way, this is the intermediate step. |
See #15983 (comment)