stdio line-streaming revisited

Sean Kelly sean at f4.ca
Thu Mar 29 18:30:48 PDT 2007


kris wrote:
> Sean Kelly wrote:
>> Andrei Alexandrescu (See Website For Email) wrote:
>>
>>>
>>> So what's the recommended use of Cout?
>>>
>>> (a) If you do stdio, use Cout (and don't forget to flush Cout 
>>> manually every time you plan to read from Cin).
>>
>>
>> Oh right, this is what tie() is for with iostreams.  It's come up 
>> before in the past, though I can't recall if any conclusions were 
>> reached. I'll admit that the current behavior is a tad confusing here 
>> though.
> 
> I'm not entirely sure what causes the sky to fall down for Andrei here? 
> Apparently there's some kind of crisis due to a need to flush a "prompt" 
> to the console before reading some related input? e.g. there's anguish over
> 
>   Cout ("name? ").flush;
>   Cin.get();
> 
> Sure, a little sugar in the form of tie() might be nice, but there's 
> nothing fundamentally wrong with the current approach as it is, IMO. 
> Anything else is just gravy. I sure hope there ain't no crisis here ;)
> 
> If I've got this wrong, Sean, I'd appreciate clarification?

No, that's exactly right.  And I think the current need for a .flush is 
consistent with how Tango IO behaves everywhere.  I suppose it would be 
nice if the feature were offered (assuming there is an elegant way to 
provide it), but the decision for whether or not to enable it by default 
for Cin/Cout is a separate issue.


Sean



More information about the Digitalmars-d mailing list