Consistency of read() and write() functions (per #14608)#14660
Consistency of read() and write() functions (per #14608)#14660JeffBezanson merged 3 commits intoJuliaLang:masterfrom
Conversation
There was a problem hiding this comment.
needs-test label is for all the new methods here and above
edit: and docs
There was a problem hiding this comment.
should be sorted, presumably?
There was a problem hiding this comment.
... and will presumably be re-sorted next time the file is generated <!-- these generated from names(Base) -->.
For now I think its better for the diff to be minimal so it is clear that a was renamed to b.
There was a problem hiding this comment.
See #8298 - "It was more of a hack and slash effort than a script. I got a list of names by calling names() in the REPL and copy/paste -ing. Perhaps I'll do an automated version one day..."
Every other renaming and refactoring that has touched this file has kept it sorted. That's easier to figure out from a diff than ignoring review and adding work to clean it up on master. Ref #9468 (comment) where this has happened before.
|
Given the ongoing discussions at #14608, I think you'd better keep your second point ( |
There was a problem hiding this comment.
closes files when done, but not ::IO inputs
There was a problem hiding this comment.
No.
A filename has no concept of open or close.
The doc says that it reads the entire contents of a file. That is what it does, open/close is hidden implementation detail. A stream may have a concept of open/close but if it does that is beyond the scope of this function, all this function does is read as a string.
|
@nalimilan has a point. Separate the rename from the new APIs into different PR's. |
4e52945 to
55f635c
Compare
|
|
|
+1 I generally like this a lot. I only wonder if |
Yeah, I went back and forth on that myself. I considered likely use cases of the methods vs orthogonality consistency.
|
There was a problem hiding this comment.
@JeffBezanson at least one use of readline(filename) already exists.
There was a problem hiding this comment.
...and good heavens, is that a /n instead of \n on the line above? Seems like it worked because the data it wants is actually the whole file (usually?). But wow.
|
Ok, I guess the extra methods are pretty harmless. In that case this just needs some tests, a rebase and a passing CI run then we can merge. |
|
new |
|
Thx for your efforts reviewing this @tkelman, I've updated doc for |
I think all the places where I've updated other tests to use the new methods provides reasonableish coverage... |
8ab65ee to
fd6b27f
Compare
|
Asside re:
It is really hard to find out how many places |
|
readlines and readuntil with a filename are not covered yet. Neither is edit: neither is |
I've made an attempt at that on a different branch... I'd rather get this PR merged and defer |
|
Hi @nalimilan, my grep-foo is quite strong ;) |
@nalimilan This should work (but I'd rather leave it for a seperate PR) ... read(s, ::Type{UTF8String}) = UTF8String(read(s))
read(s, ::Type{ASCIIString}) = ASCIIString(read(s))However, I think I'd still want to keep |
|
Note, I've added more |
5508108 to
a6309d4
Compare
Why? Defeats the point of API cleanups and renames to leave the old version in place without a deprecation. If you want the type unstable version, can make that This PR is getting too large and doing too many things at once. |
|
From PR description:
This PR is not proposing any changes to the existing Note that appveyor seems to be confused at the moment. There is a passing run for the most recent commit here : https://ci.appveyor.com/project/StefanKarpinski/julia/build/1.0.12613 |
|
There's no sense doing all the renaming to |
|
I suspect we will still want |
|
Bump. I addressed testing to some extent in this comment. In #14699 I've built a much more comprehensive I hope that this PR can be merged soon so that I can rebase #14699 and update its tests for the revised API conventions. See also #14747 re possible |
|
There's quite a bit of unaddressed review here still. When I'm at a bigger keyboard I'll collect into a checklist. Since #14699 fixes bugs and is more completely tested, I think it is in better shape to be merged first, assuming vtjnash and others have checked it for correctness. |
|
I think this is ready to merge. I agree we should suggest |
|
@nalimilan and I both disliked the docstring format here. I'll fix it myself if need be. |
|
Ok, then I think it would be best to merge this and you can fix the docstrings on master. |
Consistency of read() and write() functions (per #14608)
@samoconnor, could you make a PR for this? Thanks! |
|
|
thx @stevengj, I wonder how many of these could be replaced by a block-wise iterator (similar to |
As proposed in #14608.
The discussion in #14608 includes ideas for better ways to do things in the future.
This PR is limited to making a few tweaks to the existing interface to make it a little more consistent:
readbytesandreadall, replaced byreadandreadstring.filename::AbstractStringas 1st arg forwrite,read,read!,readuntil,readlineandreadlines.write(to::IO, from::IO)per write(to::IO, from::IO) #14628