stdio performance in tango, stdlib, and perl

Derek Parnell derek at nomail.afraid.org
Wed Mar 21 18:10:08 PDT 2007


On Wed, 21 Mar 2007 17:57:51 -0700, Andrei Alexandrescu (See Website For
Email) wrote:

> Derek Parnell wrote:
>> Actually you said "stdio also offers a readln() that creates a new line on
>> every call" and so does my fictious "io.readln(line)".  It can not
>> overwrite its buffer because it creates the buffer. 
>> 
>>   io.Status readln(out char[] pBuffer)
>>   {
>>      pBuffer.length = io.FirstGuessLength;
>>      
>>      // Note: This routine expand/contracts the buffer as required.
>>      fill_the_buffer_with_chars_until_EOL_or_EOF(pBuffer);
>> 
>>      // If I get this far then the low-level I/O system didn't fail me.
>>      return io.Success;
>>   }
> 
> Fine. It's just not clear what readln does from its signature. In 
> contrast, stdio offers size_t readln(char[]) and char[] readln(), with 
> clear semantics.
 
>>> read_delim(FILE*, char[] buf, char delim[]);
 
> It's the other way around: 

Right ... it was the "from its signature ... with clear semantics" that had
me fooled.

> My point is that at end-of-file you may want to know whether the 
> delimiter was correctly present, as is required in certain protocols.

Yes. A very good point indeed.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Justice for David Hicks!"
22/03/2007 12:07:34 PM



More information about the Digitalmars-d mailing list