Uh oh!
There was an error while loading. Please reload this page.
Amend RFC 517: Add material for stdio - #899
Conversation
Expand the section on stdin, stdout, and stderr while also adding a new section explaining the fate of the current print-related functions.
There was a problem hiding this comment.
I forgot to delete this when the std::net RFC landed.
l0kod
commented
Feb 24, 2015
The |
mahkoh
commented
Feb 24, 2015
Then they have to allocate memory first which is not acceptable. |
l0kod
commented
Feb 24, 2015
Maybe a new macro for that purpose then (e.g. |
mahkoh
commented
Feb 24, 2015
So just |
l0kod
commented
Feb 24, 2015
Yeah, not sure we want to write this for each |
aturon
commented
Feb 24, 2015
I think the move we made in Personally, I would suggest the following variant of the design for consistency:
Just to clarify why this kind of global design is useful, consider some alternatives:
On the other hand, of course it's important to provide all of the I don't think the RFC says where these constructors should live, but I would propose |
Also add back text for `foo_raw` and details.
alexcrichton
commented
Feb 25, 2015
I like the sound of all this. I've pushed an update which includes:
As @mahkoh mentioned these are fundamentally unable to prevent many calls to the |
aturon
commented
Feb 25, 2015
BTW, I strongly suggest we land some preliminary version of this ASAP, since we need to start getting feedback on the new APIs. We can and should be very clear that none of it will be stabilized until the RFC is finalized, of course. |
alexcrichton
commented
Feb 25, 2015
I have created a PR for this RFC, but I would like to stress that it is not final at all. We need to implement these APIs to allow crates to migrate to |
l0kod
commented
Feb 25, 2015
Don't forget the |
l0kod
commented
Feb 25, 2015
This API looks really like a custom implementation of a generic file-descriptor/handle type (e.g. |
alexcrichton
commented
Feb 25, 2015
We're currently leaving that for a future RFC as it's only somewhat tangentially related to the stdio bits of this RFC.
I agree! We're just not ready at this time to commit to that kind of an API. |
alexcrichton
commented
Feb 25, 2015
mahkoh
commented
Feb 25, 2015
More #ifdef hell for code that wants to be portable. At this point I would be content with |
mahkoh
commented
Feb 27, 2015
|
alexcrichton
commented
Mar 5, 2015
I've pushed an update which recommends that the raw stdio primitives are not implemented or stabilized at this time. Otherwise the interface remains the same and continues to be somewhat high level. It's quite similar to what's implemented today, but a few tweaks will be necessary for the implementation. The update also revises that @mahkoh I agree there are some interesting questions around |
There was a problem hiding this comment.
Hm, it seems this 'all' isn't quite true? (Or is it referring to the internals too.)
There was a problem hiding this comment.
How so? (I may be missing something)
There was a problem hiding this comment.
There are operations other than lock on Stdin, meaning a user can do things with it without locking. (I'm now inclined to believe I just misread: and this sentence is saying those operations would just call lock internally.)
There was a problem hiding this comment.
Ah right, yes this is just saying that all methods will call lock internally
huonw
commented
Mar 5, 2015
Hm, the windows behaviour seems to be very "fancy" to me, less minimal than we might hope for |
alexcrichton
commented
Mar 5, 2015
I agree, I'm not super comfortable about this either. I've been considering it a hard constraint though that the stdio handles must implement |
mahkoh
commented
Mar 8, 2015
This still doesn't address writing to stderr. Having to create your own thread local variable just to do some error reporting is annoying. |
alexcrichton
commented
Mar 10, 2015
Can you clarify where this thread local variable is coming from? The new primitives are not thread local, and the |
nikomatsakis
commented
Mar 10, 2015
@alexcrichton one thing I found confusing in the current text was the discussion of locking. It wasn't clear to me whether the value returned by
It may be that this text is implicitly referencing the existing API or other things with which I am unfamiliar? In general though this text sounds to me as if the locking is something the user does ("first require acquiring a lock", "relocking is not necessary", "ButRef trait will not be impemented"), but there is no coverage of what API would be offered. I am guessing that I am misinterpreting this paragraph though. |
alexcrichton
commented
Mar 10, 2015
@nikomatsakis I tried to clarify that section a bit to make it a little more explicit, but let me know if anything is off! |
Amend RFC 517: Add material for stdio
aturon
commented
Mar 13, 2015
This RFC has now been merged. It is a conservative refinement of the previous incarnation of stdio handles, in particular clarifying the interaction with Windows consoles/unicode requirements. We will definitely need to revisit this topic to introduce raw handles and redirection for |
mahkoh
commented
Mar 13, 2015
No it cannot. The RFC says that |
aturon
commented
Mar 13, 2015
I'm not referring to changing the target of |
mahkoh
commented
Mar 13, 2015
What are you thinking that you'd consider having |
nagisa
commented
Mar 13, 2015
Stdout/in/err are unlikely to ever become thread local again. We used that design in old_io and it didn’t work out. Now we have one a single handle and are locking for thread safety instead. Regarding |
mahkoh
commented
Mar 13, 2015
@nagisa: How did it not work out? Why do you think that that implies that it cannot work out?
Then libraries that want to allow having their output captured cannot use writeln? And they cannot write anything to stderr? That's ridiculous. |
mahkoh
commented
Mar 13, 2015
For example, it is a serious problem in some terminal programs that you cannot capture the output of libraries which then mess up your output. You have to hack around this by replacing fd 1 and 2 temporarily with /dev/null before library calls (e.g.). The rust stdlib should not inherit this problem. |
aturon
commented
Mar 13, 2015
The previous design made it possible to redirect
Right, so I'm wondering what proposal you have in mind? A few of your comments on this thread seem to be alluding to a design, but it'd help to see it spelled out a bit more explicitly. My main point here is that the current RFC doesn't address these problems and so we need to revisit it. Depending on the precise contract we give, it should be possible to add redirection later, but in any case we can probably address it before 1.0 regardless. |
mahkoh
commented
Mar 13, 2015
See #973 |
Expand the section on stdin, stdout, and stderr while also adding a new section
explaining the fate of the current print-related functions.
Rendered