-
-
Notifications
You must be signed in to change notification settings - Fork 746
Various std.stdio cleanups. #625
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
Conversation
std/stdio.d
Outdated
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.
FILE* and File aren't file descriptors. "File descriptor" is a POSIX term which refers to OS-level file handles, i.e. indices into a table of open files for a process. Quoting Wikipedia,
The FILE * file handle in the C standard I/O library routines is technically a pointer to a data structure managed by those library routines; one of those structures usually includes an actual low level file descriptor for the object in question on Unix-like systems. Since file handle refers to this additional layer, it is not interchangeable with file descriptor.
isFileHandle would be better, but I'm not sure if that is 100% appropriate either.
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.
I know it's not 100% accurate, but I think streaming device was a pretty bad term too... I'll rename it to isFileHandle though.
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.
Done.
|
I thought that That looks just plain wrong and would break a lot of code. Now, if anyone is using So, if we can reasonably rename |
|
I've added wrapper functions called I have, however, added |
|
Sounds sensible. I'm fine with it now. |
|
You should change the |
|
The other issue, can you get away with aliasing |
|
Done. |
|
@jmdavis It could probably be done, but... I don't know. Then we're back to square one where we introduce random exceptions to our naming conventions. With my changes, you would have to do: Which I don't think is that bad. We could of course open up the constructor so that |
|
@alexrp I don't really see that as a problem. You have to do that with all of our other range types (it's particularly nasty with Voldemort types, though still doable). They're not really meant to be held as member variables like that, but people still do it from time to time, and in this case, they've been able to do it for ages, so even if we didn't really want them doing that, changing it now could break a fair bit of code. We don't really know how much, because we don't know how many people have been doing that. The real question though is whether you can get away with making an alias of until And by the way, does making a member variable like that work with |
|
It does work. The But now I'm confused. Aliasing |
|
Yes, it was what you did initially. The problem is that in the long term, we need As for disabling |
I don't think we can have both a function and a type alias. I don't see how the compiler would disambiguate. But on the other hand, I see no reasonable deprecation path at all, then. We need to do something...
I'd argue that if people need an uninitialized |
|
We might be able to get the compiler to disambiguate if the private constructor temporarily took a useless 3rd argument, then As for unitialized If the alias doesn't work, then I'd be halfway tempted to just say screw it and risk the breakage on the theory that it should be abnormal to have the However, Steven has been working on std.io, and we could probably make the change there. Walter has insisted that its API be compatible with std.stdio, but given the way that |
|
If we can fix it in the long term in |
|
Rebased. Please review again. |
|
Okay. Looks good. |
|
Merged. |
This:
stdin,stdout,stderr.Filememberspureandnothrow.isStreamingDevicetoisFileDescriptor, deprecates the old name, and documents the new one properly.Please merge before 2.060 if possible (and changes are OK).
requires: dlang/druntime#240